POV-Ray : Newsgroups : povray.off-topic : OO theory? Python. : Re: OO theory? Python. Server Time
29 Jul 2024 04:16:57 EDT (-0400)
  Re: OO theory? Python.  
From: Darren New
Date: 20 Oct 2012 13:32:18
Message: <5082e022@news.povray.org>
On 10/16/2012 5:06, Warp wrote:
> Well, for one, methods taking 'self' as a parameter seems highly unusual

A function that takes "self" as the first argument is a method. Otherwise 
it's a function.

> Using __ as a syntax to denote a special meaning of functions and variables
> is also quite unusual,

The constructor is named __init__

The operator+ method is named __add__

And so on. It just avoids special syntax and substitutes special names.

The variable __y is just a plain old variable with the name mangled for 
pseudoreadability, exactly like naming a member variable in C++ m_xyz so you 
remember it's a member variable when you use it. Personally, I never saw the 
point. But since Python doesn't have "private" vs "public" variables, people 
have taken to using leading underscores to mean "don't touch this from outside."

 > Programming
> languages seldom give any special syntactic meaning to variables and
> function names containing underscores. (Instead, they usually use actual
> keywords to express, for example, member variable visibility.)

Unless it, say, a destructor in C++ ;-)

Honestly, I always thought naming the constructor after the class was a 
terrible decision.

> very beginning of Python, I must say that it's... unusual, to put it in
> nice terms.

It *is* unusual. It's not especially broken.

-- 
Darren New, San Diego CA, USA (PST)
   "They're the 1-800-#-GORILA of the telecom business."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.