merits of Lisp vs Python

xscottg at gmail.com xscottg at gmail.com
Fri Dec 15 04:43:24 EST 2006


Ken Tilton wrote:
> Andrew Reilly wrote:
>
> >  That all looks like data.
>
> No, not reverse, the part you did not understand. I do not mean what the
> code was doing, I meant that it was code.
>

Code is data is code - even in Python:

skills_table = [
  {
  "title": "Absolute Value",
  "annotations": ["Bleah bleah", "ho hum", "etc..."],
  "hints": ["and so on", "etc..."],
  "reverse" : (lambda x: whatever(x))
  },
  {
  "title": "Square Root",
  "annotations": ["Bleah bleah", "ho hum", "etc..."],
  "hints": ["and so on", "etc..."],
  "reverse" : (lambda x: someother(x))
  },
  # etc...
]

Of course those lambdas are crippled in Python (and not really
necessary in this bogus example)...  But that's without trying to be
clever:

class AbsoluteValue:
   title="Absolute Value"
   annotations=["Some list", "goes here"]
   @classmethod
   def reverse(cls, *args):
     # I didn't understand what your code was doing
     pass
defskill(AbsoluteValue)

That would be a reasonable place for a "pie decorator" on a class, but
I guess that's not allowed.  I doubt this second example would be
considered "Pythonic" in any case...


> >  Couldn't you do that with a table
> > containing those fields, and key it off the defskill argument (or even the
> > title?) at startup?
>
> Not the code. In reverse.
>

Why not?

Python has plenty of other flaws that I can't happily work around, and
I do think Lisp is more flexible.  However, I think your example is
readable enough with a data driven algorithm in most any popular
language.  All of the data is visible to the reverse(...) method.
Maybe I missed something in your example, but I think you aren't trying
hard enough.  :-)

The one I liked was: http://ll1.ai.mit.edu/shriram-talk.pdf

If I ever fill in your RtL survey, I'll be citing that one as a turning
point for me.


>
> Interpolation does not mean what you think it means.

I'm sure he meant "string interpolation", which is a common enough term
in scripting languages nowdays.


> It would be easier to compare and
> contrast with the Python equivalent if someone had posted such, but your
> troops have fallen back to Fort So What? and pulled up the drawbridge.
>

Oh God!  Is it just me out here?  And I'm not even a believer.

Cheers.




More information about the Python-list mailing list