[Grace-core] Default methods

Andrew P. Black black at cs.pdx.edu
Sun Feb 8 15:38:59 PST 2015


On 8 Feb 2015, at 14:10, Kim Bruce <kim at cs.pomona.edu> wrote:

> Andrew,
> 
> Does something like Java 8’s default methods (methods added to a type rather than an implementation — and not allowed to refer to instance variables) satisfy your needs for extensible primitive types?
> 
> http://zeroturnaround.com/rebellabs/java-8-explained-default-methods/
> 

I see default methods as one more patch made to cover-up a bad design decision made in 1994. 

Like James said, I don’t see how they would work with implicit typing.  In Java, when you say that an object satisfies and interface, it gets the additional methods, which must (presumably) be implemented in terms of the remainder of the interface.  We never say explicitly that an object satisfies an interface.

I suppose that when Grace gets a “no-such-method” error on a receiver r, it could look at a list of default methods and see is there is one with the right name, and then see if its required methods are supplied by r — or by other dealt methods on r, recursively.   This seems really arcane.

The right thing is to simply give the receiver the right method in the first place.  And that’s pretty easy to do, I think.

	Andrew


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailhost.cecs.pdx.edu/pipermail/grace-core/attachments/20150208/41389716/attachment.html>


More information about the Grace-core mailing list