Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Lisp is More Evaluatable

by mikfire (Deacon)
on May 24, 2001 at 08:13 UTC ( #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?


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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://82817]
[choroba]: Corion A colleague has helped me. It seems the "Modification of read-only value" was caused by old Test::More version which doesn't have done_testing, plus the old bug with $@ sometimes showing a different exception
[choroba]: will upload a fixed version and see
[Corion]: choroba: Ah, OK - sounds like a really weird combination :)

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2018-06-25 14:12 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.