Arc Forumnew | comments | leaders | submitlogin
5 points by almkglor 6154 days ago | link | parent

> How do you solve the references within modules?

Easy: redefine "def" from within a 'use form (possibly using kennytilton's faux special globals) such that it keeps a table of defined functions (which is what you intend to do anyway). Replace all locals with (uniq)'ed names (in case someone uses uses a function name as a local - (def foo () nil) (def bar (foo) (foo))) ). Then for each expression in the file, replace all symbols (outside of quote-forms) that match a key in the table to references to the table itself.



2 points by pau 6154 days ago | link

I have to start hacking this, so that the problems become apparent. But your solution seems about right...

-----

2 points by almkglor 6154 days ago | link

The hard part is the replacing of local variables with (uniq)'ed symbols. But I think local variables should be replaced anyway, because otherwise macros will override local variables with the same name.

-----

1 point by binx 6153 days ago | link

What if a "def" form is the result of macro expansion?

-----

1 point by almkglor 6153 days ago | link

What about it? Redefine "def", right? The def that gets referenced is still the same "def" you specially defined.

-----