March 25, 2008 Re: "SFINAE is Evil" | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | Bill Baxter wrote:
> Jason House wrote:
>> I look forward to when you can write more... Are you trying to say SFINAE is needed?
>
> Yes, I'm saying I haven't yet found a case where I'm using it (but that doesn't mean there isn't one!)
>
> However, I did start a thread a while back about a way to introduce /controlled/ SFINAE. Or rather a way to explicitly say you want to try something, and if it does generate an error, try something else. Compile time try-catch. Look for the subject "static try catch construct would be helpful" in this newsgroup. I still think that would be useful.
I also had the feeling of "SFINAE is needed, but I can't come up with any examples". I find it interesting that nobody posted a need for SFINAE. Because of that, and all the pitfalls, I agree that SFINAE as a default behavior is undesirable and should disapear from D.
Rather than propose an alternative to it, I wanted to understand how it should be used in D. With no examples of it, I've started leaning toward simple removal of it. I started this thread thinking the likely outcome would be something like your proposal. Now I'm thinking that SFINAE is not needed. If that's not true, I'm thinking it may be better to enhance is clauses and/or CTFE to cover the (small) capability gap.
What do you think of that? If you (and others paying attention to this thread) agree, how do we get the attention of Walter? Maybe it should be a feature request or an entry on the unofficial D wishlist?
| |||
March 25, 2008 Re: "SFINAE is Evil" | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jason House | Jason House wrote:
> I also had the feeling of "SFINAE is needed, but I can't come up with any
> examples". I find it interesting that nobody posted a need for SFINAE. Because of that, and all the pitfalls, I agree that SFINAE as a default
> behavior is undesirable and should disapear from D.
>
> Rather than propose an alternative to it, I wanted to understand how it
> should be used in D. With no examples of it, I've started leaning toward
> simple removal of it. I started this thread thinking the likely outcome
> would be something like your proposal. Now I'm thinking that SFINAE is not
> needed. If that's not true, I'm thinking it may be better to enhance is
> clauses and/or CTFE to cover the (small) capability gap.
>
> What do you think of that? If you (and others paying attention to this
> thread) agree, how do we get the attention of Walter? Maybe it should be a
> feature request or an entry on the unofficial D wishlist?
I suspect it would be quite simple to add a compiler switch to turn SFINAE on or off?
Since D2 is "experimental" anyway, we might have this switch for a few months, and then see if anybody actually used it. The default would be SF is an error.
| |||
March 25, 2008 Re: "SFINAE is Evil" | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Christopher Wright | Christopher Wright wrote:
> Jason House wrote:
>
>> Ok, so you're saying you could do without SFINAE?
>
> Yes, and I wish I could do without templates.
I don't need templates. But that's probably because I only do apps. If I were to write libraries (even for myself), then I'd expect to be using templates in many, if not most of the functions. I's just that I currently don't run into things where I'd need a template.
As for SFINAE, I can't even imagine where I'd gain with it.
| |||
March 25, 2008 Re: "SFINAE is Evil" | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Georg Wrede | Georg Wrede wrote:
> Jason House wrote:
>> I also had the feeling of "SFINAE is needed, but I can't come up with any
>> examples". I find it interesting that nobody posted a need for SFINAE. Because of that, and all the pitfalls, I agree that SFINAE as a default
>> behavior is undesirable and should disapear from D.
>>
>> Rather than propose an alternative to it, I wanted to understand how it
>> should be used in D. With no examples of it, I've started leaning toward
>> simple removal of it. I started this thread thinking the likely outcome
>> would be something like your proposal. Now I'm thinking that SFINAE is not
>> needed. If that's not true, I'm thinking it may be better to enhance is
>> clauses and/or CTFE to cover the (small) capability gap.
>>
>> What do you think of that? If you (and others paying attention to this
>> thread) agree, how do we get the attention of Walter? Maybe it should be a
>> feature request or an entry on the unofficial D wishlist?
>
> I suspect it would be quite simple to add a compiler switch to turn SFINAE on or off?
>
> Since D2 is "experimental" anyway, we might have this switch for a few months, and then see if anybody actually used it. The default would be SF is an error.
That would be great. I'd love to try out such a switch. Though at the moment it would do me no good unless it were added to D1 also. Though rather than turning it off, I'd rather have a -v kind of switch that prints out a message whenever SFINAE is invoked, maybe with an instantiation stack trace.
--bb
| |||
March 25, 2008 Re: "SFINAE is Evil" | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | "Bill Baxter" <dnewsgroup@billbaxter.com> wrote in message news:fsbp54$293h$1@digitalmars.com... > That would be great. I'd love to try out such a switch. Though at the moment it would do me no good unless it were added to D1 also. Though rather than turning it off, I'd rather have a -v kind of switch that prints out a message whenever SFINAE is invoked, maybe with an instantiation stack trace. Great idea! <narrator>And with that, the suggestion began its slow, painful descent into the depths of the unread old posts of the NG, never to be seen again or commented on by the very man who could make a difference. Months later many would reminisce about what a good idea it was, and would sigh nostalgically over their youthful optimism.</narrator> | |||
March 25, 2008 Re: "SFINAE is Evil" | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote:
> "Bill Baxter" <dnewsgroup@billbaxter.com> wrote in message
> <narrator>And with that, the suggestion began its slow, painful descent
> into the depths of the unread old posts of the NG, never to be seen again
> or
> commented on by the very man who could make a difference. Months later
> many would reminisce about what a good idea it was, and would sigh
> nostalgically over their youthful optimism.</narrator>
That about sums it up :(
| |||
March 25, 2008 Re: "SFINAE is Evil" | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jason House | Jason House wrote:
> Jarrett Billingsley wrote:
>
>> "Bill Baxter" <dnewsgroup@billbaxter.com> wrote in message
>> <narrator>And with that, the suggestion began its slow, painful descent
>> into the depths of the unread old posts of the NG, never to be seen again
>> or
>> commented on by the very man who could make a difference. Months later
>> many would reminisce about what a good idea it was, and would sigh
>> nostalgically over their youthful optimism.</narrator>
>
> That about sums it up :(
Yes, sweet. Someone should post a self-referential url in this thread so it will be easier to find and refer to it later. :-)
--bb
| |||
March 26, 2008 Re: "SFINAE is Evil" | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote:
> "Bill Baxter" <dnewsgroup@billbaxter.com> wrote in message news:fsbp54$293h$1@digitalmars.com...
>
>> That would be great. I'd love to try out such a switch. Though at the moment it would do me no good unless it were added to D1 also. Though rather than turning it off, I'd rather have a -v kind of switch that prints out a message whenever SFINAE is invoked, maybe with an instantiation stack trace.
>
> Great idea!
>
> <narrator>And with that, the suggestion began its slow, painful descent
> into the depths of the unread old posts of the NG, never to be seen again
> or
> commented on by the very man who could make a difference. Months later
> many would reminisce about what a good idea it was, and would sigh
> nostalgically over their youthful optimism.</narrator>
I created an enhancement request (#1951) for this. That should (hopefully) gain visibility with Walter (and more importantly?) Andrei, who's been known to fully flex C++'s templates. Feel free to add individual ideas on what might be a good alternative to SFINAE. I really didn't put any in the enhancement request.
| |||
March 26, 2008 Re: "SFINAE is Evil" | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | Bill Baxter wrote: > > I don't have time to write more right now, but > Lutz Kettner gives a pretty good examples of using SFINAE here: > http://www.mpi-inf.mpg.de/~kettner/courses/lib_design_03/notes/meta.html#Constraining > > http://www.mpi-inf.mpg.de/~kettner/courses/lib_design_03/notes/meta.html#Classification > > Upon reading that, it's amazing how much more simple(and powerful) meta-programming is in D. (having static if, is-expressions, aliases, and D template syntax) -- Bruno Medeiros - MSc in CS/E student http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply