Function types as classes 
    Mark Reinhold 
    mr at sun.com
       
    Thu Dec 10 21:54:32 PST 2009
    
    
  
> Date: Thu, 10 Dec 2009 23:39:30 +0100
> From: Patrick Wright <pdoubleya at gmail.com>
> Should I assume in reading the Staw Man Proposal (SMP) that when I
> read "function type" I should understand that to be some Class, and we
> assign instances of that function type?
Whether a function type is actually a Class is an open question, I think,
although I suspect that's where we'll end up.  Whatever they are, it must
be possible to declare variables of function type, and assign functions
to them.
>                                         If so:
> 
> #int() fortyTwo = #()(42);
> #int() fortyTwoTwo = #()(42);
> 
> assert !(fortyTwo == fortyTwoTwo)
Right.
> but what about
> assert (fortyTwo.equals(fortyTwoTwo))
> 
> which maybe is a way of asking, is any #int() equal to any other
> #int()? What about hashCode()?
Closure equality should be object identity, and closure hash codes should
be identity hash codes.
(Well, I suppose we could consider two closures to be equal if they refer
 to the same bytecode and if their saved lexical bindings are all .equals,
 but I don't really see the point.  This is never something that any Lisp
 has done, so far as I know.)
- Mark
    
    
More information about the lambda-dev
mailing list