Boost logo

Proto :

Subject: Re: [proto] Recursive functions in a mini language
From: Eric Niebler (eric_at_[hidden])
Date: 2010-08-10 00:41:14


On 8/9/2010 5:39 PM, Manjunath Kudlur wrote:
>> Actually, I think your users will be forced to do: (module->*func)(...)
>> because of the precedence. That's pretty ugly. But I see where you're
>> going. Your scheme could be made to work as you describe, I think.
>
> Yes, you are right, I had forgotten about the precedence.
>
>> I'm left wondering why you want this, though. In what way is it better
>> than just defining some mutually recursive functions?
>
> How would you do that? Do you have some other mechanism in mind?

I was just talking about plain ol' vanilla C-style functions. Kickin' it
old school.

> To be
> clear, I want the ability to "name" some proto expressions, and freely
> "call" these expressions in other expressions in a mutually recursive
> manner, just like in the example I have shown. My use case is to
> provide the user with a set of data-parallel primitives that he can
> freely compose to form bigger functions.

Now I have a very fuzzy picture, but it's still not clear yet. Anyway,
it seems like an interesting programming challenge so I took a crack at
it myself. I got distracted so didn't finish it, but here's what I came
up with so far.

The biggest problem I saw was that the syntax "module.func(a,b,c)" can
mean two different things. When building the symbol table, it should
create an expression template. But outside of symbol-table-building, it
should actually evaluate the function, using the symbol table to
statically look up the functions to evaluate. This is tricky! But I
think it can be accomplished by using two different domains. I am too
tired to explain what I mean, so I'll just post what I have so far and
hope that you'll get the idea.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com



Proto list run by eric at boostpro.com