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

Simplify simple macros #127

Open
porky11 opened this issue Sep 26, 2016 · 0 comments
Open

Simplify simple macros #127

porky11 opened this issue Sep 26, 2016 · 0 comments

Comments

@porky11
Copy link
Contributor

porky11 commented Sep 26, 2016

instead of
(qq a (uq b) (uq c))
you would rather like to write
(make-macro (a b c)) and this could simply be done with mfor

(qq mfor b ((uq b))
  (mfor c ((uq c))
    (a b c)))

this is useful if there are only a few variables, that would be unquotet, but are often used inside the macro, like in some macro I used, where I don't want to write (uq …) for each variable (see end of this comment)

but when there are many variables, this will get complicated, so something like
(make-macro list-of-variables ...body) would be more clear in such cases, where list-of-variables would be similar to a list in let

  ;;part of my macro
    (qq mfor T (uq types)
      (mfor N (uq nums)

        (implement BasicMath T)

        (instantiate Array T N)
        (instantiate basic-math (Array T N))

        (def dot (fn intern T ((x (Array T N)) (y (Array T N)))
          (+ (* (@$ x 0) (@$ y 0)) (* (@$ x 1) (@$ y 1)))))

        (instantiate Array T 3)

        (instantiate Ball T N)
        (instantiate collide (Ball T N))
        (def-ptr-macro2 collide intern (Ball T N))
    …))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants