### Infix.lsp as macro

Posted:

**Tue Jun 27, 2017 7:01 am**Hi,

is it possible to transform the infix.lsp to a "true" macro i.e. doing the work at compile time ?

Or do i miss a critical point there ?

Calling "eval" during runtime is supposed to be expensive (at least in other lisps). Not sure how newlisp handles eval.

Reason for asking is that i redo some of the quaternion calculus as well as geographic math scripts.

i.e.

(INFIX:xlate "εk2 = aekb1 - aejbi + aeibj + aebk + akbe - ajbei + aibej + a1bek")

--> (setq εk2 (add (add (sub (add (add (add (sub aekb1 aejbi) aeibj) aebk) akbe) ajbei)

aibej) a1bek))

(INFIX:xlate "e3Xe4_x = sin(y3 - y4) * sin((x3 + x4) / 2) * cos((x3 - x4) / 2) - sin(y3 + y4) * cos((x3 + x4) / 2) * sin((x3 - x4) / 2)")

--> (setq e3Xe4_x (sub (mul (mul (sin (sub y3 y4)) (sin (div (add x3 x4) 2))) (cos (div (sub x3 x4) 2)))

I still can't wrap my mind around the lisp math syntax ... old school i fear ...

is it possible to transform the infix.lsp to a "true" macro i.e. doing the work at compile time ?

Or do i miss a critical point there ?

Calling "eval" during runtime is supposed to be expensive (at least in other lisps). Not sure how newlisp handles eval.

Reason for asking is that i redo some of the quaternion calculus as well as geographic math scripts.

i.e.

(INFIX:xlate "εk2 = aekb1 - aejbi + aeibj + aebk + akbe - ajbei + aibej + a1bek")

--> (setq εk2 (add (add (sub (add (add (add (sub aekb1 aejbi) aeibj) aebk) akbe) ajbei)

aibej) a1bek))

(INFIX:xlate "e3Xe4_x = sin(y3 - y4) * sin((x3 + x4) / 2) * cos((x3 - x4) / 2) - sin(y3 + y4) * cos((x3 + x4) / 2) * sin((x3 - x4) / 2)")

--> (setq e3Xe4_x (sub (mul (mul (sin (sub y3 y4)) (sin (div (add x3 x4) 2))) (cos (div (sub x3 x4) 2)))

I still can't wrap my mind around the lisp math syntax ... old school i fear ...