Kalinni Gorzkis scripsit: > Macros are like functions, but arguments are passed to them with their > original syntax, instead of evaluated.
They are not. Macros are (conceptually, and often actually) expanded *before* run time, whereas functions are called at run time. > You can already emulate [fexprs] with functions that are called like > (macro ‘(anything you want) ‘(just everything she wants)) That is also not the case, because Scheme does not have an `eval` function with access to lexical bindings. Suppose you have a procedure `choose` that works like `if` but accepts three arguments: (define (choose p t e) (if p (eval t) (eval e))) Now invoke it like this: (let ((a 1) (b 2)) (choose #t 'a 'b)) The call to `eval` within `choose` will look in the global environment for the definition of `a`, and will not find the value 1 bound in the lexical environment. (In fact, this does not work, because you must explicitly specify which global environment you want `eval` to use.) > Scheme is intended to be a language which is designed to be small but > powerful and flexible. Up to a point. > There have been recent interests in reintroducing fexprs to Lisp. Many > newer Lisp dialects, for example newLISP and Kernel include fexpr. Newlisp is dynamically scoped, like Elisp; unlike Elisp, it has namespaces. The only way to re-create the safe lexical scoping of Scheme within Newlisp is to have one namespace per function. That may be a reasonable approach to Lisp, but it is not Scheme. As for Kernel, it is closer to Scheme in some ways, but further away in others. It too is a reasonable approach to Lisp. > So I propose to reintroduce fexprs, or first-class macros, into Scheme. > What do you think? I think it would be a serious mistake. -- John Cowan [email protected] http://ccil.org/~cowan If I have not seen as far as others, it is because giants were standing on my shoulders. --Hal Abelson _______________________________________________ Scheme-reports mailing list [email protected] http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
