new enum idiom
Robert Amesz
rcameszREMOVETHIS at dds.removethistoo.nl
Sat Jan 13 17:40:53 EST 2001
Harald Hanche-Olsen wrote:
>+ rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz):
>
>| Alex Martelli wrote:
>|
>| Ah, Lisp, so beautiful, so pristine, so ... verbose. Well, it's
>| great for lists, but anything numeric is a chore. Let's see:
>| (EQ (PLUS 1 1) 2)
>| t
>| Phew, so least that's still true... ;-)
>
>Which is an accident of the implementation, in the same sense that
>the following is accidentally true in python:
>>>> 1+1 is 2
>1
In python you're quite right, as this example shows:
>>> 101+101 is 202
0
>I'm sure you meant to write (= (+ 1 1) 2) ?
Oh, sure, if you insist on using *modern* Lisp idiom. <g>
Regarding the EQ, IIRC for numerical arguments it should do a
normal comparison, at least in the dialect I used some years ago.
(Remember XLisp?) For lists it only returns t if they're strictly
equal, not structurally equal, so in that respect it works the same
as 'is' in Python. I could (maybe should) have used EQUAL or = of
course, but, as you might have guessed, I felt like being
deliberately obtuse. ;-)
>One neat thing about Lisp though, is how you can rewrite the syntax,
>for example to allow you to write infix arithmetic if you wish.
>This takes much of the pain out of involved numerical work. I wrote
>some scheme macros once (many years ago) to accomplish this - it was
>only a moderate amount of work.
True, the paradigm of Lisp is that all data structures are lists - or
cons-cells, rather - including the language itself.
>In Common Lisp you can accomplish much the same thing even more
>elegantly using reader macros.
The problem with reader macros is, however, that there's (generally)
no way of translating back. You could be in for a shock if you need
to debug that code later on. Mind you, similar things can be said if
you're a C-programmer and put too much code into your #define macros.
And, though it isn't mentioned often, the same goes for C++'s
templates.
>but-now-I-have-a-feeling-we're-in-the-wrong-newsgroup-ly y'rs,
Right you are. Back to Python it is.
Robert Amesz
More information about the Python-list
mailing list