[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string parsing/preparation for latex

From: Stephen Compall
Subject: Re: string parsing/preparation for latex
Date: Sun, 13 Nov 2005 21:17:28 -0600

On Wed, 2005-11-09 at 07:24 -0600, Jon Wilson wrote:
> scheme->LaTeX would have to be a macro, then it receives its arguments
> before they are evaluated.  Unless of course I'm mistaken about the
> nature of macros.  (I'm still relatively new to the idea.)

Yes, but you'd lose more than you'd gain by making it a macro.  Unless
you really wanted to do something crazy like:

(define-syntax scheme->LaTeX
  (syntax-rules (+ /)
    ((_ (+ f1 f2 ... f3))
     (string-append "(" (scheme->LaTeX (+ f1 f2 ...))
                    " + " (scheme->LaTeX f3) ")"))
    ((_ (+ f1))
     (scheme->LaTeX f1))
    ((_ (/ f1 f2 f3 ...))
     (string-append "\frac{" (scheme->LaTeX f1)
                    "}{" (scheme->LaTeX (* f2 f3 ...)) "}"))
    ;;and so on....

Of course that has many drawbacks of its own.  Better to just handle it
in functions, which, for example, wouldn't have the spurious parenthesis
problem of the multiple + argument syntax, and so on.  Not to mention
the added benefit of scheme->LaTeXing forms unknown at load-time without
using eval.

Remember Norvig's first step to writing a macro: Decide if the macro is
really necessary.

Stephen Compall

Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]