in reply to Using functional abstraction in Perl

in response to your latest remark, this is *exactly* the kind of thing I would use OO Perl for. What I don't see in your meditation is what you think makes a functional Lisp approach actually superior to using an OO Perl approach in this specific instance, aside from the Lisp gurus saying so.


Remember rule one...
  • Comment on Re: Using functional abstraction in Perl

Replies are listed 'Best First'.
Re^2: Using functional abstraction in Perl
by spurperl (Priest) on Jul 02, 2005 at 09:20 UTC
    As I said, this can be done with OO. But in many cases OO is less elegant and is an overkill.

    In the given example, would an OO solution suit better ? A Java-school person would probably define a class for "variable", a class for "binding" and a class for "bindings", all interrelated. So much complexity and code for such simple a mission.

    OO is nice in many situations, but it's not as nice in others. Sometimes the OO technique of "data and the actions taken on it" aren't justified as the data + actions are not as tightly coupled. It is also a leftover from a too strict typesystem, which Perl (like Lisp) fortunately lacks. In Perl a reference can be any data you can imagine. It can be a reference to a scalar, it can be a reference to a HoAoH. Only the functions working on this data know its internal structure. In Java, a class is necessary to define a new type for the data, in Perl there are other (often better) ways.