Python vs Lisp: was RE: how to pass the name of a variable as argument?



Readers of Stavros' note may be assuming that a lisp pointer is the same as
a C pointer, which it may not be.
After all, the Lisp pointers may (and often do) have type tags, and may be
shifted since they
do not need to point to bytes, but to double-words (etc).

Since C is used to implement Lisp in most instances, C can do the job, with
some effort.


> -----Original Message-----
> From: macrakis at gmail.com [mailto:macrakis at gmail.com] On 
> Behalf Of Stavros Macrakis
> Sent: Thursday, May 15, 2008 7:04 AM
> To: Dave
> Cc: Richard Fateman; maxima at math.utexas.edu; Robert Dodier
> Subject: Re: [Maxima] Python vs Lisp: was RE: how to pass the 
> name of a variable as argument?
> 
> On Thu, May 15, 2008 at 1:52 AM, Dave <dfeustel at mindspring.com> wrote:
> > On Wed, May 14, 2008 at 09:19:07PM -0700, Richard Fateman wrote:
> >>> On 5/14/08, Dave <dfeustel at mindspring.com> wrote:
> >>> > Would using Haskell for the top level be feasible?
> >>> That seems interesting, mostly, from my point of view, 
> because Haskell has built-in pattern matching. I don't know 
> anything about it, but it seems likely it is more powerful 
> than Maxima's pattern matching.
> 
> Algebraic pattern matching is different from generic tree 
> pattern matching.
> 
> >>One issue with taking a language that you like and having 
> it "call Maxima" is that most languages cannot do much of 
> anything with the return value unless the return value is numeric.
> >>...The situation is not entirely different if you 
> substitute Python for FORTRAN.
> 
> Not true.  Python, Java, and C++ are perfectly fine manipulating tree
> structures.  Of those, though, the only one really plausible as an
> interactive language is Python. You could even write (quite
> straightforwardly) code to translate between Maxima-style arithmetic
> tree structures to Python-like arithmetic tree structures and back, if
> you wanted to (say) evaluate numerically in Python.  Not entirely
> clear why you'd want to do that though -- Python arithmetic is slower
> than translated Maxima code and much slower than compiled Maxima code.
> (I haven't done the test, but I've seen benchmarks.)
> 
> >>And if use another language for the top level, you need to 
> deal with quoting and evaluation.
> 
> Agreed.
> 
> >>Lisp knows about symbols and such. There is a symbol table 
> that lives at run-time.  This is very handy for symbolic math.
> >>Some languages do not have such a run-time structure, or if 
> they do, it is not easily accessible to the programmer (that 
> is, it is used by the
> >>debugger).
> 
> Python actually has all this, though not as conveniently 
> accessible as in Lisp.
> 
> > In view of your interest in pattern matching, I suggest 
> Snobol4 as a possible front end for Maxima. Snobol4 is the 
> best pattern matching and manipulation language I have used.
> 
> Snobol4 has a very nice way of writing quite general backtracking
> pattern-matchers for strings. Though I suppose you can use its
> succeed/fail system in combination with its data structure facility to
> do pattern matching on trees, that would be a silly thing to do, as it
> is easy enough to write a backtracking pattern matcher in Lisp.  Or
> you could treat arithmetic expressions as strings -- but that would be
> insane.
> 
> All in all, though I think Python is a better language in many ways
> than the current Maxima language, I don't think that it could be used
> directly, though there is certainly a lot to learn from it.
> 
>          -s
>