4 ms·
If you think that the operator in a Lisp form needs to be a function and if it were a function that it needs to return, then that's not the case in Lisp for pro
by lispm 4y ago
If you think that the operator in a Lisp form needs to be a function and if it were a function that it needs to return, then that's not the case in Lisp for probably 50+ years.
Lisp is not generally following an eval/apply model and/or call/return model.
(send foo :beep)
This can mean:
* SEND is a function, it's is called with the evaluated args, it may return or not
* SEND is not a function and does something arbitrary
Generally the model is:
(operator ...)
a) Where operator can be a special operator, something built-in, which is not a function.
For example (throw 'foo "hello"), where THROW is a built-in special operator which transfers control.
b) it could be a function, which is more like a procedure. The function could also do transfer control to some other place and never return, for example by calling THROW or by other operators which transfer control
c) it could be a macro. The args don't need to be evaluated. Thus no eval/apply. The macro returns code, which gets executed. Again this could use other primitives, which transfer control.
d) it could be a function itself like ((lambda (x y) ...) 13 14)
What it needs: the first element in a Lisp form needs to be an operator, which is usually a symbol with some meaning: special operator, function, macro.
Scheme then in the mid 70s added that the first element is evaluated and can be a general variable. Thus in Common Lisp:
(let ((actor (create-actor :name 'foo)))
(send-async actor :init))
could be written in Scheme
(let ((actor (create-actor 'foo)))
(actor :init))
given that the actor would be a function object.
> my-actor async messge_args
Writing it as
(send my-actor :async message-args)
Is basically just a syntactic transformation. The semantics could be the same.
If we want write
(my-actor async message-args)
then one would typically
a) switch to a model like in Scheme, where the actor would be a function object
or
b) write a translator for a new language to ordinary Lisp
or
c) write a new evaluator for that