Re: Very poor Lisp performance



Brian Downing wrote:
> In article <m2iry1q2j6.fsf@xxxxxxxxxxxxxxx>,
>> I'm not sure it's been established that Mathematica has macros that
>> are similar in power to Lisp's macros. If you want to see what an
>> honest attempt to combine infix operators with Lisp-style macros looks
>> like you should check out Dylan or (more recently) the Java Syntactic
>> Extender[1]. However to understand the comparison you'll, of course,
>> have to learn something about Common Lisp macros. And if you really
>> want to go to town, look into Scheme's various macro systems which
>> offer a slightly different take on the problem.

Can you give me a reference explaining the difference between Lisp and
Scheme here? I didn't realise this existed...

> To Mathematica's credit its syntax always boils down to it's own
> funny-looking sexprs:
>
> (2 + {3, 4, 5}) ~Frob~ x is really Frob[Plus[2, List[3, 4, 5]], x]

Yes, exactly.

> So given that you can programmatically manipulate Mathematica symbolic
> expressions, it's probably not a stretch to say that in theory you can
> generate arbitrary code like you can with CL macros.

Absolutely. In this respect, I do not think you can get any more general
than Mathematica. The main disadvantage is the performance cost of this
generality. On the other hand, I believe you can replace the lexer
(reader?) in Lisp, which you cannot do in Mathematica.

> The problem, as mentioned in another branch of the thread here, is that
> the Mathematica syntax is incredibly complicated to support some of this
> flexibility, and the Mathematica evaluator is so /incredibly/ complex as
> to basically prohibit understanding of what's going to happen when
> things are evaluated, at least for me.

Not really. It took me 4 days to write a mini-Mathematica implementation in
OCaml. Once you are familiar with Mathematica, it is fairly obvious what's
going on "under the hood".

> There's certainly no concept of "macroexpansion time" and "run time" like
> there is in CL,

So you cannot use macros to generate code to generate macros to generate
code in Lisp?

> and there's no simple QUOTE operator

What does the quote operator do?

> - things keep evaluating until they stop changing
> unless wrapped in special Hold forms that have to stick with it to keep
> it from evaluating in the future.

Yes. I thought that was a direct equivalent of QUOTE.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com
.



Relevant Pages

  • Re: something to chat about, lisp and Mathematica for list processing.
    ... If Lisp macros count then Mathematica replacement rules should count. ... kind of a read-applyrules-print loop. ...
    (sci.math.symbolic)
  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... > mathematica does, and therefore that is how lisp does ... I was not trying to infer how Lisp evaluates ... So macros are the only remaining point of interest. ... functions mapping ASTs to ASTs. ...
    (comp.lang.lisp)
  • Re: Lisps QUOTE and Mathematicas "Hold"
    ... >> algebra system written in Lisp, simulating Mathematica. ... > Not macros, functions mapping ASTs to ASTs. ... Then you should check out Lisp. ...
    (comp.lang.lisp)
  • Re: Very poor Lisp performance
    ... >> Presumably that is a Lisp-specific problem because Mathematica has no ... >> problem using infix notation... ... > are similar in power to Lisp's macros. ... it from evaluating in the future. ...
    (comp.lang.lisp)
  • Re: Evaluating Latex in Mathematica
    ... my LateX output using a mathematics evaluation environment (currently ... Mathematica allows you to paste LateX ... what to do with Macros. ...
    (comp.text.tex)