Of what use is 'lambda'???
Kragen Sitaker
kragen at dnaco.net
Mon Sep 25 16:01:09 EDT 2000
In article <39CF7C9F.315AAD67 at san.rr.com>, Darren New <dnew at san.rr.com> wrote:
>Kragen Sitaker wrote:
>> "referentially transparent" is another way of saying "has no side
>> effects".
>
>Actually, "referentially transparent" implies there are no side effects, but
>the opposite is not necessarily true. This is actually one reason I dislike
>Perl.
>
>@x = (3, 2, 1)
>$y = @x
>$z = (3, 2, 1)
>
>Here $y != $z
>
>Maybe that's just because assignment is explicitly a side-effect in Perl.
>It's hard to argue one way or the other. But the first statement still
>stands. :-)
You could argue that the commas in the two occurrences of (3, 2, 1)
were different operators because of Perl's context-sensitivity; whether
or not perl thinks so is probably arguable:
perl -MO=Terse -e '@x = (3, 2, 1); $y = @x; $z = (3, 2, 1)'
-e syntax OK
LISTOP (0xc75c0) pp_leave
OP (0x135290) pp_enter
COP (0xc7530) pp_nextstate
BINOP (0xc06c0) pp_aassign [2] (array assign)
UNOP (0xbfc70) pp_null [141]
OP (0xc8958) pp_pushmark
SVOP (0xc0740) pp_const IV (0xc7bac) 3
SVOP (0xc0720) pp_const IV (0xc7ba0) 2
SVOP (0xc06e0) pp_const IV (0xc9c50) 1
UNOP (0xc7620) pp_null [141]
OP (0xd20c8) pp_pushmark
UNOP (0xc07a0) pp_rv2av [1]
GVOP (0xc0780) pp_gv GV (0xc9c2c) *x
COP (0xc74a0) pp_nextstate
BINOP (0x12fbc0) pp_sassign
UNOP (0xc07e0) pp_rv2av [3]
GVOP (0xc00c0) pp_gv GV (0xc9c2c) *x
UNOP (0xc0760) pp_null [15]
GVOP (0xc0700) pp_gvsv GV (0xc9c14) *y
COP (0xc7590) pp_nextstate
BINOP (0x144e40) pp_sassign (scalar assign)
LISTOP (0xc7470) pp_list (see, this was pp_null above)
OP (0x135308) pp_pushmark
OP (0x12fc20) pp_null [5] (and the 3 and 2 have been optimized away)
OP (0x144e80) pp_null [5]
SVOP (0x144e60) pp_const IV (0xc9c98) 1
UNOP (0x144ea0) pp_null [15]
GVOP (0x12fbe0) pp_gvsv GV (0xc7bc4) *z
If they're different operators that just happen to be spelled the same
way --- like Python's list-index and create-an-anonymous-list operator,
both spelled with [] --- then you could argue that the above expression
is indeed referentially transparent, just not transparent in the sense
of "clearly readable to human beings".
--
<kragen at pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we ourselves
possess.
-- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"]
More information about the Python-list
mailing list