[ABE.pm] non-trivial closure examples?

Ricardo SIGNES perl.abe at rjbs.manxome.org
Fri Aug 8 15:02:47 PDT 2008


* "Faber J. Fedor" <faber at linuxnj.com> [2008-08-08T17:47:55]
> On 08/08/08 15:52 -0400, Ricardo SIGNES wrote:
> > * "Faber J. Fedor" <faber at linuxnj.com> [2008-08-08T13:57:52]
> > > I've got the canonical example of a closure, now I'm looking for
> > 
> > Make sure you explain closures first.  Java doesn't have them.
> 
> Really?  I was under the impression they could do them but the syntax is
> horrible. Unfortunately, I can't find the reference right now.

Nope.

  http://www.google.com/search?ie=utf8&oe=utf8&q=java%20closure

They don't really need them, because...

  http://www.kimbly.com/blog/000063.html

> > > Memoize would not be a good example since I would have to explain
> > > everything Memoize is trying to accomplish..
> > 
> > Memoize is a pretty good example.  All you have to explain is how it makes
> > fibbonacci faster.
> 
> I'm sure that's high on their to-do list. :-)

Sure, but any competent programmer will be able to go from that application to
understanding others.  Alternately, avoid fibb, since it brings recursion to
the table.  Instead, you can use it for some other expensive operation, like
parsing the contents of an XML file into an immutable tree, or computing the
primality of a number.  That example has the benefit of being useful either
recursively or not.

-- 
rjbs


More information about the ABE-pm mailing list