Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 20, 2006 indefinable type | ||||
---|---|---|---|---|
| ||||
dg is a delegate and must return a value of the same type as it self. What should "some_type" be to make this work? some_type delegate() dg; /*********/ while( (dg = dg()) !is null){} (in case you are wondering this would act as a finite state machine) |
February 20, 2006 Re: indefinable type | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | BCS wrote:
> dg is a delegate and must return a value of the same type as it self. What
> should "some_type" be to make this work?
>
> some_type delegate() dg;
I don't think this is currently possible in D.
Sean
|
February 21, 2006 Re: indefinable type | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | I think you could use "static if (is(typeof(dg) T))" to do this, more or less. Not sure, would have to mess with it. Read more here: http://www.digitalmars.com/d/expression.html#IsExpression -[Unknown] > dg is a delegate and must return a value of the same type as it self. What > should "some_type" be to make this work? > > some_type delegate() dg; > > /*********/ > while( (dg = dg()) !is null){} > > > (in case you are wondering this would act as a finite state machine) > > |
February 21, 2006 Re: indefinable type | ||||
---|---|---|---|---|
| ||||
Posted in reply to Unknown W. Brackets | I did manage a hack around using a struct something like
struct foo
{
foo delegate() dg;
}
foo dgv;
while(dgv.dg !is null)dgv = dgv.dg();
If function ptrs are used a cast to void* works.
Unknown W. Brackets wrote:
> I think you could use "static if (is(typeof(dg) T))" to do this, more or less. Not sure, would have to mess with it.
>
> Read more here:
> http://www.digitalmars.com/d/expression.html#IsExpression
>
> -[Unknown]
>
>
>> dg is a delegate and must return a value of the same type as it self. What
>> should "some_type" be to make this work?
>>
>> some_type delegate() dg;
>>
>> /*********/
>> while( (dg = dg()) !is null){}
>>
>>
>> (in case you are wondering this would act as a finite state machine)
>>
>>
|
Copyright © 1999-2021 by the D Language Foundation