[e-lang] Names. Caps vs static types?

Mark Miller markm at cs.jhu.edu
Thu Apr 14 22:31:13 EDT 2005


Mark Miller wrote:
> ... MarcS's logger pattern ...:
> 
>   def makeLogger(accessedObject, recipientName, logWriter) {
>       def logger {
>           match [verb, args] {
>               logWriter.println(“Access: “ + recipientName)
>               logWriter.println(“Method: “ + verb)
>               for each in args {
 >                   logWriter.println(“    with arg: “ + each)
 >               }
>               E.call(accessedObject, verb, args)
>           }
>       }
>       return logger
>   }
> 
> In a dynamically type-safe system such as ... Java, this
> kind of thing can be expressed trivially. ...

I should clarify. In Java, this kind of thing can only be expressed for the 
subset of accessedObject's methods whose introducing declaration is in an 
interface rather than a class. Even with this restriction, it's still tricky 
to express the above in raw Java. But most of the work can be encapsulated in 
a helper abstraction (see Deflector.java in the E-on-Java implementation). 
Given such a helper, the above pattern can indeed be expressed trivially in 
Java. The returned logger object would be an instance of an on-the-fly 
synthesized type that implements all the public interfaces implemented by 
accessedObject.

This means we should expect Joe-E (along with E, Oz-E, Squeak-E, and Pyth-E) 
to provide better support for writing new access abstractions than we should 
expect from an ML-E. Of course, this only applies to the subset that actually 
materializes ;).

-- 
Text by me above is hereby placed in the public domain

     Cheers,
     --MarkM



More information about the e-lang mailing list