Thread overview |
---|
February 05, 2008 OpIn | ||||
---|---|---|---|---|
| ||||
I can't seem to find any docs about this, and I'm too thick to understand it. for example: use(context) in (GL gl) { draw(gl);}what the hell is this? How does it work? Why would one wan't it? etc...Explain it to me like I'm a retard, because I am. As far as I understand, "context" in this case is a delegate, which has gl as "in" and.. now what?thanks |
February 05, 2008 Re: OpIn | ||||
---|---|---|---|---|
| ||||
Posted in reply to dominik | dominik wrote:
> I can't seem to find any docs about this, and I'm too thick to understand it.
>
> for example:
>
> use(context) in (GL gl) { draw(gl);}what the hell is this? How does it work? Why would one wan't it? etc...Explain it to me like I'm a retard, because I am. As far as I understand, "context" in this case is a delegate, which has gl as "in" and.. now what?thanks
>
>
use is presumably a function that returns a temporary struct.
The temporary struct defines opIn.
The (GL gl) { } is a delegate literal that takes a GL parameter.
So this code calls the temporary struct's opIn with a (void?) delegate(GL).
Hope it helps.
--downs
|
February 05, 2008 Re: OpIn | ||||
---|---|---|---|---|
| ||||
Posted in reply to downs | On Tue, 05 Feb 2008 13:23:24 +0100, downs wrote:
> use is presumably a function that returns a temporary struct.
>
> The temporary struct defines opIn.
>
> The (GL gl) { } is a delegate literal that takes a GL parameter.
>
> So this code calls the temporary struct's opIn with a (void?)
> delegate(GL).
so basically all of this "in" and delegate literal is something like a fancy callback?
|
February 05, 2008 Re: OpIn | ||||
---|---|---|---|---|
| ||||
Posted in reply to dominik | dominik wrote:
> On Tue, 05 Feb 2008 13:23:24 +0100, downs wrote:
>> use is presumably a function that returns a temporary struct.
>>
>> The temporary struct defines opIn.
>>
>> The (GL gl) { } is a delegate literal that takes a GL parameter.
>>
>> So this code calls the temporary struct's opIn with a (void?)
>> delegate(GL).
>
> so basically all of this "in" and delegate literal is something like a fancy callback?
>
Basically, yes. :)
I love D, among other things, for its ability to easily declare and pass around small snippets of behavior, i.e. delegate literals :)
--downs
|
Copyright © 1999-2021 by the D Language Foundation