self.python vs Current.eiffel

Quinn Dunkan quinn at seniti.ugcs.caltech.edu
Sat Sep 30 05:19:43 EDT 2000


On 26 Sep 2000 13:29:42 GMT, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl>
wrote:
>Tue, 26 Sep 2000 15:56:53 +0200, Egbert Bouwman <egbert at bork.demon.nl> pisze:
>
>> I am lost. What are the differences between python's self and x,
>> and Eiffel's Current and x ?
>
>Python allows assignments to arbitrary fields of arbitrary objects,
>but does not bring instance variables into the current namespace.
>So they must always be accessed through an explicitly written object,
>no matter if it's self or something other.
>
>Eiffel only allows assignment to self's fields (and local variables).
>It does bring them into the namespace, so they can be referred to
>with or without Current, but assigned to - only without Current, as
>it would me meaningless anyway to have something other than Current
>in an assignment.

Not totally meaningless, there's always local variables.  sather has a self
like eiffel's Current, but it does allow assignment.  This means you can do:

class VAL is
    attr val:INT;
    double_val is
        val ::= 2;
        self.val := self.val * val;
    end;
end;

I think this is just a "feature" of eiffel's idea of Current, not any
fundamental reason having to do with namespaces.  sather branched off from
eiffel way early, and I gather "Current" is a newish eiffel feature, so it's
not surprising Current and self are different.

So how are you supposed to have confusing variable names in eiffel if you
can't assign to Current?  Or is Meyer just being Mr. Correct and not allowing
us our little perversities?  :)



More information about the Python-list mailing list