Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Lisp is More Evaluatable

by mikfire (Deacon)
on May 24, 2001 at 08:13 UTC ( [id://82817]=note: print w/replies, xml ) Need Help??


in reply to Lisp is More Evaluatable

I may be approaching this a little simplisticly, but I do not usually think of using a function reference as eval'ing ( pardon me while I make up a few words ).

The reason eval $x; doesn't "work" is that you are using a reference in scalar context, which has the well defined behaviour of stringifying the reference. I like this feature - it makes it easy to figure out how to access information deep withing a complex data structure.

The $x->() format tells perl to dereference instead of stringify. This is again a standard syntax in perl. $x->{foo} access that key from a hash reference. Similarly from an array reference. Why do you expect a different syntax simply because it is a function reference?

eval is there for two purposes:

  • Roughly equivalent to "try/catch" in other languages. This allows me to do something potentially fatal ( like use a module that doesn't exist ) without hurting myself. I most often use this construct in DBI code when I need to roll back a transaction if it fails.
  • To run code generated at runtime. Personally, I haven't yet had the need to use eval in this form, but I am certain other monks can expand on this point.

I am not a perl fanatic. I fully recognize each language has its purpose. I have never used lisp in any sense other than a college class, but I thought it was pretty fun. If you understand lisp better than perl, and it does the job you need, than by all means use it.

Comparing one language to another seems pretty useless to me - each language is designed to solve a unique problem space. Would you also claim that a hammer is better than a screw driver? I guess I am asking, with respect, what the point of this node was?

mikfire

Replies are listed 'Best First'.
Re: Re: Lisp is More Evaluatable
by novitiate (Scribe) on May 24, 2001 at 14:08 UTC
    ...and that is the essence of perl

    Let's get on with the perl instead of these comparisons....
    what next, perl vs. awk|sed ?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://82817]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (None)
    As of 2024-10-15 19:01 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.