[Baypiggies] Frequently Argued Objections

Alex Martelli aleax at google.com
Mon Jun 23 17:40:19 CEST 2008

On Mon, Jun 23, 2008 at 7:41 AM, Warren Stringer <warren at muse.com> wrote:
> My guess is that:
>        1)  9 times out of 10 the var in self.var is blindingly obvious,
>        2) 99 times out of 100 it is obvious after a 10 second search,

I think that there are way more than 1 in 100 uses even just for the
simplest example that shows this guess to be unfounded: "self.var = x"
which would allowed to become "var = x"  under a deleterious "implicit
self" rule.

Right now, "var = x" sets a local variable in the method, "self.var =
x" sets an instance variable: zero ambiguity, zero chances for error,
zero problems -- well let's say epsilon problems rather than zero,
because there IS the issue of having to listen to whines against
"mandatory explicit self";-).

There are good ways and bad ways to address this issue during language
design. The best way -- as in Modula-3, Python, Perl-5, Ruby -- is to
explicitly mark instance variables (self.var in Modula-3 and Python,
$self->{var} in Perl-5, @self in Ruby); a somewhat inferior way -- as
in Squeak -- is to give up some of the language's dynamic nature by
forcing variables to be declared; a worse way would be to break
symmetry by using the explicit mark in assignment but not in

The very worst way is shown by Javascript's "with" statement -- within
a Javascript "with zap", the meaning of "zop = 23" is essentially
unguessable as it depends on whether zap already did have a zop
attribute (in which case it rebinds it) or not (in which case it binds
a global variable -- unless there was an earlier declaration of "var
zop" in this function, in which case it binds the local variable
instead) -- a mix of forced declaration and blind guessing that good
books on Javascript (e.g. the short and useful "Javascript, the good
parts") strive to convince the reader to never, ever use that accursed

Within the "explicit mark" camp, Ruby's "@var" is typographically
concise but conceptually bends Occam's razor -- it makes the language
introduce one more rule (on the meaning of a "@" prefix) where the
choice that Python took from Modula-3 just reuses an existing rule
(whatever.var means exactly the same in all cases, whether "whatever"
is "self" or something other than "self" -- no special cases, no extra


More information about the Baypiggies mailing list