gorillascript icon indicating copy to clipboard operation
gorillascript copied to clipboard

Modularity and scoping of macros

Open andreyvit opened this issue 12 years ago • 4 comments

  1. How are we supposed to reuse/distribute macro libraries? Would be REALLY great to load macros using the same rules as Node's require.
  2. Can I, say, write my own class macro to redefine the language for a single file?
  3. Any reason why FunctionDeclaration is a built-in thingie rather than defined via macro syntax?

I know I can just read the code at this point, but still, this needs to be in the docs so hopefully a ticket is useful.

andreyvit avatar Jul 08 '13 00:07 andreyvit

  1. A file can import another file, which only allows importing of consts and macros. e.g. import 'shared.gs'.
  2. Not currently, but you could define a macro called myclass with similar semantics. Currently macros are interpreted in-order, so having a macro that matches first will never carry through to one that redefines it. Perhaps I could reverse the order so that newest macros are used first. That would probably work best.
  3. Ease at the time. It also contains a lot of conditional logic and such, and the if macro uses a function (as a way to mitigate looping), so having to define what a function declaration is before defining if would be complex given the amount of logic that takes place within a function declaration. Perhaps I'll look into it again, though.

ckknight avatar Jul 08 '13 03:07 ckknight

With #128, You can now override macros, making your second point handled.

ckknight avatar Jul 16 '13 00:07 ckknight

@ckknight Nice, thank you! Should I make separate issues for the remaining two items, and then close this issue? Or maybe only for the first one?

andreyvit avatar Jul 16 '13 08:07 andreyvit

Just the first one, I'd say, as I don't plan on changing FunctionDeclaration to a non-builtin due to the complexity.

ckknight avatar Jul 16 '13 21:07 ckknight