Serialization
Peter Levart
peter.levart at marand.si
Wed Dec 16 01:06:46 PST 2009
For the "name" part, maybe alternative is specifying it directly in the lambda expression like this:
#int(int, int) plus = #(int a, int b) a+b; // produces annonymous class name, sensitive to position in source
vs.
#int(int, int) plus = #Plus(int a, int b) a+b; // producess named inner class in the namespace of outer class
I think there's no way to automatically identify a closure so that the identification would move with it when you reorder code without attaching the identification on the lambda expression itself.
Peter
On Wednesday 16 December 2009 09:21:18 Mike Swingler wrote:
> Is there a definition for how annotations are added to lambdas?
> Perhaps a unique name and/or serial id could be added that way.
>
> ~Mike
>
> On Dec 16, 2009, at 12:05 AM, Joshua Bloch wrote:
>
> > Mike,
> >
> > I'm skeptical about this approach; using hashes for serial version
> > UIDs was a disaster, for any number of reasons. Hashes are so
> > fragile. Change anything and things blow up at runtime. I wish I
> > believed this approach would work, but I'm afraid it probably won't.
> >
> > Sorry,
> >
> > Josh
> >
> > On Tue, Dec 15, 2009 at 11:13 PM, Mike Swingler <swingler at apple.com>
> > wrote:
> > Perhaps the class and defining method name could be concatenated
> > with a hash of the contents of the function.
> >
> > Cheers,
> > Mike Swingler
> >
> >
> > On Dec 15, 2009, at 10:58 PM, Joshua Bloch wrote:
> >
> > Mark,
> >
> > I'm sorry to say, I don't know. It's a hard problem. One
> > possibility is to
> > provide a concise syntax for named singleton subclasses of
> > functional types.
> > That would finesse the problem rather than solving it.
> >
> > Josh
> >
> > On Tue, Dec 15, 2009 at 10:38 PM, Mark Reinhold <mr at sun.com> wrote:
> >
> > Date: Tue, 15 Dec 2009 22:17:41 -0800
> > From: Joshua Bloch <jjb at google.com>
> >
> > This is a moderately important decision. In Google's Java MapReduce
> > API,
> > we use
> > SAM interfaces to represent Mapper and Reducer. Instances must be
> > serializable,
> > as they're serialized to pass them from the node that starts the
> > MapReduce to
> > the worker nodes (which do the actual mapping and reduction). That
> > means
> > we
> > won't be able to use closure syntax for MapReduce, which seems like a
> > shame.
> >
> > This is no worse than what we do with SAM types today, but it's no
> > better,
> > either. Can we do better?
> >
> > Maybe. How would you suggest we address the concerns which Peter
> > raised?
> >
> > - Mark
> >
> >
> >
> >
>
>
>
More information about the lambda-dev
mailing list