John Porter <jdporter@min.net> writes: > Ariel Scolnicov wrote: > > > > No, what Perl has that Python doesn't is good-clean-CS-theory > > *closures*. Both languages let you have functions as (nearly) > > first-class objects > > Perl closures can be perl objects (no "nearly" about it): > > bless sub { ... }, $class; That's not quite what I meant. If I take say "bless $ref, 'Foo'" then I get a Foo object, no matter what $ref was originally referring to (think of that as the implementation of Foo). But what sub { ... } returns is a function reference (just like [1,2,3,] returns a list reference). The term "first-class object" itself has little to do with object-oriented programming (see, e.g., _Structure and Interpretation of Computer Programming_). It means that the language gives functions the same treatment as its other objects (can be stored in variables, passed to and returned from functions, etc.). The main reason I wouldn't call function references "first-class objects" is that the language itself sometimes bypasses the function object mechanism (e.g. "sort { $a <=> $b } @list"). -- Ariel Scolnicov |"GCAAGAATTGAACTGTAG" |ariels@compugen.co.il Compugen Ltd. |Tel: +972-2-6795059 (Jerusalem) \ We recycle all our Hz 72 Pinhas Rosen St. |Tel: +972-3-7658514 (Main office)`--------------------- Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555 http://3w.compugen.co.il/~ariels ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe