Thanks, I applied the patch and compiled FriCAS to see its result.

You are right, it is working.

The thing confused me is that, this is double compilation.

First, the SPAD compiler complies *.spad to *.lsp with this macro.
Then, when *.lsp are read and compiled, this macro works at compile time.

I have no further questions.

- Qian

On 3/9/21 12:58 AM, Waldek Hebisch wrote:
On Tue, Mar 09, 2021 at 12:31:34AM +0800, oldk1331 wrote:
But this macro only expands to this function call, it does not do
computation at compile time.


No.  Macro is executed at compile time and result used as expansion.
Most of our macros use "`" (backtick) to delay evaliation and
just insert some variable pieces inside, like:

(defmacro QAREF1(v i)
`(aref (the (simple-array T (*)) ,v) ,i))

Here backtick means that main part will be taken literaly and
only 'v' and 'i' replaced by parameters.  But in

(defmacro |mk_DF|(x e) (|make_DF| x e))

there is no backtick, so it runs at compile time.  See:

(1) -> )lisp (macroexpand '(|mk_DF| 17 -3))

Value = 0.017
(1) -> )lisp (macroexpand '(QAREF1 17 -3))

Value = (AREF (THE (SIMPLE-ARRAY T (*)) 17) -3)

Of course, in the second case code is wrong because 17 is not a
vector and -3 is not valid index (negative).  But 'macroexpand'
does not execute code (and in some weird context this code
could be valid, so 'macroexpand' just dully performs expansion).


--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/2cc20bb2-05d7-4d21-449f-147146f71f40%40gmail.com.

Reply via email to