Nп/п : 15 из 93
 От   : none) (albert                       2:5075/128        07 июл 23 14:15:27
 К    : All                                                   07 июл 23 15:21:14
 Тема : IMMEDIATE and def_macro
----------------------------------------------------------------------------------
                                                                                 
@MSGID:
f1c445a7
@REPLYADDR none) (albert
@REPLYTO 2:5075/128 none) (albert
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID:

@TZUTC: 0200
@TID: FIDOGATE-5.12-ge4e8b94
I`m trying to implement mal on ciforth
https://github.com/kanaka/mal
Amounts to implementing a dialect of lisp using a dialect of Forth.

In step 8 I encounter the following:

-Add a new attribute is_macro to mal function types. This should
  default to false.

Am I mistaken or is this the familiar immediate flag added to
Forth definitions?

- Add a new special form defmacro!. This is very similar to the def!
  form, but before the evaluated value (mal function) is set in the
  environment, the is_macro attribute should be set to true.

Much like colon definitions, later to be modified by IMMEDIATE to add
that behaviour.

-  Add a macroexpand function: This function takes arguments ast and env.
   It calls is_macro_call with ast and env and loops while that condition
   is true. Inside the loop, the first element of the ast list (a
   symbol), is looked up in the environment to get the macro function.
   This macro function is then called/applied with the rest of the ast
   elements (2nd through the last) as arguments. The return value of the
   macro call becomes the new value of ast. When the loop completes
   because ast no longer represents a macro call, the current value of
   ast is returned.

How is this different from executing an immediate definition in
the middle of deferring an action? The only difference seems
to be that Forth does this much cleaner and with less caveats.
First and foremost it is far easier to keep track of arguments.
They reside on the stack.

Am I the first to notice this? Chuck Moore was a student of McCarthy.
Perhaps he invented Forth as a simpler version of lisp.

Groetjes Albert
-- 
Don`t praise the day before the evening. One swallow doesn`t make spring.
You must not say "hey" before you have crossed the bridge. Don`t sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning.            - the Wise from Antrim -
--- trn 4.0-test77 (Sep 1, 2010)
 * Origin: KPN B.V. (2:5075/128)
SEEN-BY: 5005/49 5015/255 5019/40 5020/715 848 1042
4441 12000 5030/49 1081
SEEN-BY: 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх