Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Re: First char out of a string & surprises with errors on chop reverse $string (that doesn't work!)

by merlyn (Sage)
on Dec 26, 2001 at 21:55 UTC ( [id://134435]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: First char out of a string & surprises with errors on chop reverse $string (that doesn't work!)
in thread First char out of a string & surprises with errors on chop reverse $string (that doesn't work!)

How often have you wanted to say:
reverse $foo = "merlyn";
in sensible code? That's why it doesn't return an lvalue!

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Re: Re: First char out of a string & surprises with errors on chop reverse $string (that doesn't work!)
by eduardo (Curate) on Dec 26, 2001 at 22:03 UTC
    Definite agreement... reverse $foo = "merlyn"; makes little to no sense. However, chop reverse $foo; does seem relatively reasonable... (though I see how it quickly goes to hell in a handbasket.) I remember when in my Data Structures in C++ class they tried explaining the reason to overload some operators as lvalues, and some not... it always seemed like you could *find* a scenario where you may want that functionality (though I doubt 2 + 2 = $foo; would ever be a good one :) Well... thanks to everyone for the answers! I am going to agree that it really makes very little sense to let reverse return an lvalue... though I think the obfuscation "value" alone may warrant it :)
      though I doubt 2 + 2 = $foo; would ever be a good one :)
      "2 + 2 equals $foo, for certain values of 2"... hmmm...

      No, really, i think 2 + $bar = 3 would be a nice way to write $bar = 1, but _very_ hard to make.

      2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-03-19 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found