January 05, 2007 Re: D mixins | ||||
---|---|---|---|---|
| ||||
Posted in reply to mike | mike wrote:
> Am 05.01.2007, 00:19 Uhr, schrieb Waldemar <waldemar@wa-ba.com>:
>
>>> >> Well coming from C++ this would not make much sense. Where would you
>>> >> use them in C++? Where would you use them in D? Are there any
>>> good D
>>> >> examples that show the power of mixins in a simple way that would be
>>> >> more ugly another way?
>>
>> Roughly speaking, anytime you see a multiline #define macro in C++ (especially
>> with parameters), you would use a mixin in D.
>>
>> That's only one sample use, but it should speak to the Cplusplusers.
>>
>
> Erm ... I don't think you can insert this line via a mixin into a certain scope:
>
> ' scope (failure) dosomething();
>
> But, please, tell me I'm wrong, I would really need that :)
>
> -mike
>
> --Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
Sadly, no, you cannot do that, because templates (perhaps mixins should be their own type? er, nevermind that) have their own evaluation scope, with the outer scope "friended" in. So, scope guards will execute on the templates's own scope rather than the host's. I've actually tried this, with my fingers crossed. All to no avail. (It would've been a darn nifty way to do selective tracebacks. But alas.)
-- Chris Nicholson-Sauls
|
January 05, 2007 Re: D mixins | ||||
---|---|---|---|---|
| ||||
Posted in reply to mike | mike wrote: > Am 05.01.2007, 00:19 Uhr, schrieb Waldemar <waldemar@wa-ba.com>: > >>> >> Well coming from C++ this would not make much sense. Where would you >>> >> use them in C++? Where would you use them in D? Are there any >>> good D >>> >> examples that show the power of mixins in a simple way that would be >>> >> more ugly another way? >> >> Roughly speaking, anytime you see a multiline #define macro in C++ (especially >> with parameters), you would use a mixin in D. >> >> That's only one sample use, but it should speak to the Cplusplusers. >> > > Erm ... I don't think you can insert this line via a mixin into a certain scope: > > ' scope (failure) dosomething(); It's just a wild guess, but... are you trying to get a backtrace of some sort ? If so, you might want to try the one from Shinichiro: http://shinh.skr.jp/d/ -- Tomasz Stachowiak |
January 05, 2007 Re: D mixins | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Nicholson-Sauls | == Quote from Chris Nicholson-Sauls (ibisbasenji@gmail.com)'s article > mike wrote: > > Am 05.01.2007, 00:19 Uhr, schrieb Waldemar <waldemar@wa-ba.com>: > > > >>> >> Well coming from C++ this would not make much sense. Where would you use them in C++? Where would you use them in D? Are there any > >>> good D > >>> >> examples that show the power of mixins in a simple way that would be more ugly another way? > >> > >> Roughly speaking, anytime you see a multiline #define macro in C++ > >> (especially > >> with parameters), you would use a mixin in D. > >> > >> That's only one sample use, but it should speak to the Cplusplusers. > >> > > > > Erm ... I don't think you can insert this line via a mixin into a certain scope: > > > > ' scope (failure) dosomething(); > > > > But, please, tell me I'm wrong, I would really need that :) > > > > -mike > > > > --Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/ > Sadly, no, you cannot do that, because templates (perhaps mixins should be their own type? > er, nevermind that) have their own evaluation scope, with the outer scope "friended" in. > So, scope guards will execute on the templates's own scope rather than the host's. I've > actually tried this, with my fingers crossed. All to no avail. (It would've been a darn > nifty way to do selective tracebacks. But alas.) > -- Chris Nicholson-Sauls I was not aware of that, but the post was intended for C++ users. Most, if not all, C/C++ ugly macros can be nicely written as mixins in D. Now, getting back to D, I suppose one could write the scope functionality "by hand" (the "C++ way") into a mixin! Inserting it would produce the desired effect. That's a theory at the moment, I do not have a code. |
January 05, 2007 Re: D mixins | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom S | Am 05.01.2007, 05:11 Uhr, schrieb Tom S <h3r3tic@remove.mat.uni.torun.pl>: > > It's just a wild guess, but... are you trying to get a backtrace of some sort ? If so, you might want to try the one from Shinichiro: http://shinh.skr.jp/d/ > > > -- > Tomasz Stachowiak Exactly. I've seen that a couple of days ago, downloaded it, but I didn't dare to install it, because it says it's for version 0.176 or so and I wanted to wait until it's officially supporting 1.0 and do the mixin backtrace in the meantime. Does it work with 1.0? Any experience? -mike -- Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/ |
January 05, 2007 Re: D mixins | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Nicholson-Sauls | Am 05.01.2007, 04:28 Uhr, schrieb Chris Nicholson-Sauls <ibisbasenji@gmail.com>: > Sadly, no, you cannot do that, because templates (perhaps mixins should be their own type? er, nevermind that) have their own evaluation scope, with the outer scope "friended" in. So, scope guards will execute on the templates's own scope rather than the host's. I've actually tried this, with my fingers crossed. All to no avail. (It would've been a darn nifty way to do selective tracebacks. But alas.) > > -- Chris Nicholson-Sauls I wanted to do tracing this way as well (see my other reply). I've actually started to go through all my code and copy/paste the scopeguards at the beginning of each function. But, mixin or not, it's just too much to insert those statement in 30k or so lines of code, I'll rather just try out if the modified phobos that was linked to a couple of times here in the ng works with 1.0 :) -mike -- Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/ |
January 05, 2007 Re: D mixins | ||||
---|---|---|---|---|
| ||||
Posted in reply to mike | mike wrote:
> Am 05.01.2007, 05:11 Uhr, schrieb Tom S <h3r3tic@remove.mat.uni.torun.pl>:
>> It's just a wild guess, but... are you trying to get a backtrace of some sort ? If so, you might want to try the one from Shinichiro: http://shinh.skr.jp/d/
>
> Exactly.
> I've seen that a couple of days ago, downloaded it, but I didn't dare to install it, because it says it's for version 0.176 or so and I wanted to wait until it's officially supporting 1.0 and do the mixin backtrace in the meantime. Does it work with 1.0? Any experience?
No experience, sorry.
But the binary is pretty much guaranteed not to work; there have been some ABI changes since v0.176.
You could try diffing the provided sources to the originals from DMD 0.176 and applying the patches to the current Phobos though.
|
January 05, 2007 Re: D mixins | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frits van Bommel | Frits van Bommel wrote:
> mike wrote:
>> Am 05.01.2007, 05:11 Uhr, schrieb Tom S <h3r3tic@remove.mat.uni.torun.pl>:
>>> It's just a wild guess, but... are you trying to get a backtrace of some sort ? If so, you might want to try the one from Shinichiro: http://shinh.skr.jp/d/
>>
>> Exactly.
>> I've seen that a couple of days ago, downloaded it, but I didn't dare to install it, because it says it's for version 0.176 or so and I wanted to wait until it's officially supporting 1.0 and do the mixin backtrace in the meantime. Does it work with 1.0? Any experience?
>
> No experience, sorry.
> But the binary is pretty much guaranteed not to work; there have been some ABI changes since v0.176.
> You could try diffing the provided sources to the originals from DMD 0.176 and applying the patches to the current Phobos though.
I think it's just some changes to object.d, deh.c, deh2.d, dmain2.d, from internal, and a new module in std: symtable.d. The merge should be pretty straightforward.
Sean
|
January 05, 2007 Re: D mixins | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote:
> Frits van Bommel wrote:
>> You could try diffing the provided sources to the originals from DMD 0.176 and applying the patches to the current Phobos though.
>
> I think it's just some changes to object.d, deh.c, deh2.d, dmain2.d, from internal, and a new module in std: symtable.d. The merge should be pretty straightforward.
That's why I suggested trying it :).
|
Copyright © 1999-2021 by the D Language Foundation