[Tutor] methods versus functions (using lists as an example)

Alan Gauld alan.gauld at freenet.co.uk
Thu Oct 21 09:36:43 CEST 2004


> > use symbols as part of names (@foo) for special purposes - like
> > class members etc.
>
> Strangely, that's a feature I actually like. It makes it easier to
> identify what a variable is. Besides, the use of symbols is IMO far
> less baroque than what's done in Perl,

NO argument there, its only a couple of cases in Ruby, in Perl
its virtually everything that gets line noise added.

> fooBar: variable
> FOOBAR: constant
> FooBar: class
> _fooBar: instance variable

I use all of those except the latter. However none of these
conventions
reduces the readability of the words, they are still plain English.But
I guess you could counter with the double __  magic variable thing in
Python but an underscore is visually separate from the letters since
its on the baseline of the word - like the ruled lines on a page...

> ever): the lack of proper private variables/methods (Ruby does have
> such a thing).

Ah but I never see that as a problem. I've never quite understood
the paranoia that drives people to make things private. I guess its
because all the OOP languages I first used (with the exception of
Smalltalk) all had public members. (They were mainly Lisp variants
and some early C bolt ons)

I can honestly say that in 15 years of using OOP I've never had
a single bug due to something being public rather than private.
But I've had dozens of bugs due to things being declared private
when they should have been 'protected' instead.

> We'll have to see what happens when Parrot finally hits 1.0 and we
can
> use the CPAN modules with Python and Ruby (not to mention the added
> speed)... We'll dig that thread out in about ten years, I guess...
:p

Indeed, but much will depend on it working performantly as well
as functionally. The harsh reality is that people will rarely
accept any significant performance hit to use foreign modules
- even if the performance isn't critical! :-)

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld/tutor2/



More information about the Tutor mailing list