Let me ask the question slightly differently. Without constraining yourself 
to legal Julia syntax, what would you like to go in, and what do you want 
to come out? I get the feeling there's a design here that doesn't have this 
complexity--my intuition is that a generic function can be used to drive 
this just fine (called within a macro to facilitate the final splice.) But 
that's still hard to concretely suggest. 

On Saturday, April 4, 2015 at 9:39:57 PM UTC-5, Abe Schneider wrote:
>
> I don't understand how what I'm trying to do falls outside the domain of 
> transforming code. My main goal is to take a user-defined grammar and 
> create relevant code.
>
> More to the point, I think the general ability to generate expressions 
> based on functions/namespaces is also solidly in the domain of transforms. 
> I can imagine plenty of use-cases for language-bindings, communication, etc.
>
> Yes, there are many simple macros one can create, which are useful, but 
> there exists many useful things one can do with macros that can get more 
> complex.
>
> A
>
> On Saturday, April 4, 2015 at 10:11:25 PM UTC-4, Jameson wrote:
>>
>> I think the underlying issue may be that you are trying to have the macro 
>> do too much, when you should instead be just doing source-code transforms 
>> and preprocessing. One such example of a great use of a macro is simply:
>>
>> macro special_foo(syntax_tree)
>>     return quote
>>         special_foo( $(QuoteNode(syntax_tree) )
>>     end
>> end
>>
>>
>> On Sat, Apr 4, 2015 at 8:05 PM Abe Schneider <abe.sc...@gmail.com> wrote:
>>
>>> The issue I'm dealing with is that I have a macro that I want to pass a 
>>> list of functions that the macro can employ for parsing grammars. The macro 
>>> itself exists already, and it currently has its own static list of 
>>> functions. I'm trying to figure out a way to allow the user of the library 
>>> to customize it.
>>>
>>> For example:
>>> @grammar foo begin
>>>   start = list(integer, r", ")
>>> end
>>>
>>> where `list` is a user supplied function. The issue that I keep running 
>>> into is that there doesn't seem to be any easy way of just passing in a 
>>> function to a macro. Turning an expression into a function is problematic, 
>>> because `eval`s are: (a) only work in the modules namespace, and (b) are 
>>> frowned on.
>>>
>>> I've thought about manually looking up the symbol name in the various 
>>> namespaces, but while I've found methods to list the functions, I haven't 
>>> found a way to do the reverse.
>>>
>>> Ideally, it would be nice to generate an expression with `call` that 
>>> took a symbol and a namespace, that way no lookups would have to be done.
>>>
>>> Having hit a dead end in this direction, it occurred to me that it might 
>>> be possible to do something like this:
>>> @set_parsers(list, etc)
>>> @grammar foo begin
>>> ...
>>> end
>>>
>>>
>>> where '@set_parsers` would generate the `@grammar` macro with the static 
>>> list it already has plus whatever else the user adds in.
>>>
>>> Which works, except for the whole module issue.
>>>
>>>
>>> Thanks,
>>> A
>>>
>>>
>>> On Saturday, April 4, 2015 at 12:41:27 PM UTC-4, Patrick O'Leary wrote:
>>>>
>>>> On Saturday, April 4, 2015 at 9:04:10 AM UTC-5, Abe Schneider wrote:
>>>>>
>>>>> I should start off, not entirely sure this is an okay thing to do with 
>>>>> Julia. Suppose I want to create a macro that generates another macro...
>>>>>
>>>>
>>>> I'm not sure whether this should work or not, but either way I'm not 
>>>> sure how it's any more expressive than macros alone? Can you describe what 
>>>> it is you want to do at a high level in a little more detail? There might 
>>>> be another way. 
>>>>
>>>

Reply via email to