Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macros cannot reference functions defined in the program. #94

Open
riatzukiza opened this issue Jun 9, 2016 · 0 comments
Open

Macros cannot reference functions defined in the program. #94

riatzukiza opened this issue Jun 9, 2016 · 0 comments

Comments

@riatzukiza
Copy link

riatzukiza commented Jun 9, 2016

Since programs made by the compiler are never evaled in the compiler scope, macros cannot make reference to functions that are defined in the program except through use in expanded forms, so it is difficult to make use of libraries to handle the arrays, and what ever other various things you might do inside of a macro, with our directly defineing them in the macro, or using a meta tag to append the functions definition to the global scope.

Even then, if you have a set of functions that operate on arrays that you like to use in general, for every function there must be two definitions

(defun y (a b) `(cdr (list ,a ,b)))
(defmacro x (a b) (y a b))
(let ((a 0) (b 1))
  (x a b));;(x a b) -expands to-> (CDR (LIST A B))

The above is some common lisp, here there was a function y defined, and it was then used inside of the macro x.

to do the same thing in sibilant right now would require the following.

;;not valid.
(def y (a b) `(cdr (list @a @b)))
(macro x (a b) (y a b))
;;valid
(macro x (a b)
       (def y (a b) `(cdr (list @a @b)))
       (y a b))

Which then makes using y in other macros impossible.

This could be solved by evaluating every form defined immediately after expansion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant