[Grace-core] Fwd: Some notes on pattern matching on the wiki

Ewan Tempero e.tempero at cs.auckland.ac.nz
Tue Jul 5 16:12:42 PDT 2011


On 06/07/11 00:42, James Noble wrote:
>> I went through a phase in my early days of Java programming when I used "this" for all self calls (and access to fields) only to find it totally was wrong in the context of nested classes.
>
> Hmm.. ?

Perhaps it is more accurate to say that with nested classes there is no way to give an 
explicit receiver for messages sent to objects in the enclosing class:

class Outer {
   void out() { ... }
   class Inner {
     void in() {
       out(); // this.out() does the wrong thing
     }
   }
}

> how ugly is it to have to write self._foo  and self._bar(x,5) all the time to access "private" stuff?

very ugly. The kind of ugly that would put people off, primarily because it would require 
typing "self." a whole lot, and would totally pollute the code ("self." is all you would 
see when looking at it). It's this kind of thing that puts people of BEGIN END instead of 
{}. (IMHO of course)

> (an evil option could allow "_" as a substitute for "self." for private things, but that seems several more steps too far)

In which case what does "self." really mean? I think any syntax that looks like 
<receiver>. should be dynamic and lack of receiver is lexical. It satisfies my need for 
clearly signalling what's going on by just looking at the thing (not needing to look at 
the context) while providing fairly succinct syntax.

--ewan


More information about the Grace-core mailing list