forward references... again?

Regan Heath regan at netmail.co.nz
Tue Sep 27 02:37:19 PDT 2011


On Mon, 26 Sep 2011 19:07:59 +0100, Mehrdad <wfunction at hotmail.com> wrote:

> On 9/26/2011 10:56 AM, Jonathan M Davis wrote:
>> On Monday, September 26, 2011 10:13 Mehrdad wrote:
>>> On 9/26/2011 9:36 AM, bearophile wrote:
>>>> In similar situations I suggest you to minimize your code, so both you
>>>> ans us are able to better see the situation and the problem. Doing
>>>> that you often don't need help. Bye, bearophile
>>> Hope this is better:
>>>
>>> void main() {
>>> (Test() + Test()).get(0.0);
>>> }
>>>
>>> struct Sum(T1, T2) {
>>> T1 a;
>>> T2 b;
>>>
>>> auto ref get(T2...)(T2 args) {
>>> return (a + b).get(args); // Why is calling get() considered a
>>> "forward reference"?
>>> }
>>> }
>>>
>>> struct Test {
>>> auto ref get(T2...)(T2 value) { return 0; }
>>>
>>> Sum!(typeof(this), T2) opAdd(T2)(T2 other) const {
>>> return typeof(return)(this, other);
>>> }
>>> }
>> I'm not sure, but I would have expected that reusing T2 in th template  
>> of the
>> get function would cause problems. At best, that T2 is shadowing the  
>> outer T2.
>> You should be using a different name for get's template parameter.  
>> Maybe that
>> has something to do with the problem, and the error message is just bad.
>>
>> - Jonathna m Davis
> Nah, that's not the issue. Originally it was a different name, it just  
> so happened that I didn't notice this in the simplification.
>
> However, I DID find the problem -- it's because the function is  
> recursive. :(
> What I _meant_ to say was a.get(args) + b.get(args), but I said (a +  
> b).get(args).  So it was pretty much calling itself.

So.. bug report for the bad error message then?

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list