March 09, 2013
On Saturday, 9 March 2013 at 16:05:59 UTC, Andrei Alexandrescu wrote:
> On 3/9/13 10:22 AM, monarch_dodra wrote:
>> BTW, in regards to template constraints (not the rest), he does have a
>> point. We have raised the exact same issues here on the boards more than
>> once.
>
> What was the problem for D again?
>
> Andrei

"Problem" is a big word. But basically, the combination: "if your template type doesn't meet template constraints, where did it fail?" We don't have that, but concepts do. This is part of the:
- Should we use constraints only for overloads or also to validate types?
- Should we instead use static asserts to find out why the argument type is wrong?

 That said, concepts (afaik) don't handle overloads...

...which brings us to managing said overloads. Basically, right now, if you want overloads, you have to repeat the conditions in a:

if (a && !b)
...
if (b && !c)
...
if (c)

This is minor, but it does not scale very well, especially if "a", "b" and "c" are complicated. In algorithm, some of our constraints for sort/find can be 5 lines long. At this point, can we still say that they are readable tools for users, or an implementation tool for dispatch?

Things can get evenmore hairy,when you are operating on 2 different types.

One last thing to keep in mind is that having constraints allows hijacking, whereas concpets/static asserts resolve as an ambigus call.

----
Not a breaking issue or anything, just more of an anoyance. I wanted to point out that we ourselves have already had talks about the points raised in said article.

Regardless, that was not the main point that I was trying to get accross. My main point was simply that what works for D might not be best for C++.
March 09, 2013
On Saturday, 9 March 2013 at 15:22:55 UTC, monarch_dodra wrote:
> On Saturday, 9 March 2013 at 14:09:39 UTC, Andrei Alexandrescu wrote:
>> On 3/8/13 7:48 PM, DypthroposTheImposter wrote:
>>> See the static_if paper here:
>>>
>>> http://isocpp.org/forums
>>>
>>> Under the post "constraints and static if" there is a link to a
>>> document about
>>> static_if
>>>
>>> https://docs.google.com/viewer?a=v&pid=forums&srcid=MDIyMDc3NjUwMTczOTM0Mjk3NjABMDI2MzM3MjkxNDM4NDQ5MzE4NDcBLWVsS1Y4dFhtdDhKATUBaXNvY3BwLm9yZwF2Mg
>>>
>>>
>>> Are they full of it? Has it caused the problems they mention
>>> in
>>> D?
>>
>> Wow. That's quite out of character for Bjarne. I think it's quite a poor piece.
>>
>> Andrei
>
> I think there is a bit of forced bashing in there, but the main point is that static if prevents eager semantic validation of templated code. In C++, if you write a semantically incorrect template, then the compiler can catch it. This is not possible once static ifs enter the picture.
>
> I know for a fact I've had the C++ compiler catch a fair amount of errors for me, whereas it takes actual intantiation for the D compiler to catch said errors (and I've seen a few such errors in phobos).
>
> I think the main point is not "is static if good or not": I think D has clearly demonstrated how powerful it can be. However, to the question of "is it the right move for C++, whith all of its heritage, to adopt static if?" As a C++ developper, honestly, I'm not sure it is. I think that's where the piece is comming from, in maybe a clumsy manner.
>
> C++ took a different road with its "horrible" template syntax, but it took that road. I think it is better to improve that road (with concepts, for example), then try to move the current paradigm.
>
> That's might point of view having mostly a "full C++" background, and having learned D. The bottom line, I think, is that it is an error to think of D as "just" improved C++, and that what might work for D might not be what is best for C++. It doesn't mean that static if (or other D constructs) are bad in and out of themselves. I wouldn't take this piece as a "direct attack" on D.
>
> ...
>
> BTW, in regards to template constraints (not the rest), he does have a point. We have raised the exact same issues here on the boards more than once.

The more I think of it, the more this whole duck typing for templates is probably a bad solution because we lack tool to express « meta types ».
March 09, 2013
On 03/09/2013 03:15 AM, Artur Skawina wrote:

>   - static-if not creating scopes /is/ confusing, but what would be a better
>     alternative?

I am surprised that << and >> are never mentioned:

    static_if >>
        void foo();
    <<

Problem solved. ;)

Ali

March 09, 2013
On Saturday, 9 March 2013 at 17:51:31 UTC, Ali Çehreli wrote:
> On 03/09/2013 03:15 AM, Artur Skawina wrote:
>
> >   - static-if not creating scopes /is/ confusing, but what
> would be a better
> >     alternative?
>
> I am surprised that << and >> are never mentioned:
>
>     static_if >>
>         void foo();
>     <<
>
> Problem solved. ;)
>
> Ali

static if(condition) «
    void foo();
»

Let's do it with style ;)
March 09, 2013
Note that there will be a teleconference Tuesday with one important point:
 "Discuss whether to continue work on static if, or to focus work on
concepts lite."
See:
https://groups.google.com/a/isocpp.org/forum/#!topic/concepts/AMVFwQGgS3c

I'm pointing that in case Alexandrescu and Walter didn't know and want to defend their paper.

Joel Lamotte


March 09, 2013
On 03/09/2013 12:10 PM, deadalnix wrote:
> On Saturday, 9 March 2013 at 17:51:31 UTC, Ali Çehreli wrote:
>> On 03/09/2013 03:15 AM, Artur Skawina wrote:
>>
>> > - static-if not creating scopes /is/ confusing, but what
>> would be a better
>> > alternative?
>>
>> I am surprised that << and >> are never mentioned:
>>
>> static_if >>
>> void foo();
>> <<
>>
>> Problem solved. ;)
>>
>> Ali
>
> static if(condition) «
> void foo();
> »
>
> Let's do it with style ;)

I love how the second set show up in two different styles on my computer.
March 09, 2013
On 03/09/2013 01:33 AM, Nick Sabalausky wrote:
> On Sat, 9 Mar 2013 02:08:07 -0500
> Nick Sabalausky<SeeWebsiteToContactMe@semitwist.com>  wrote:
>
>> On Sat, 09 Mar 2013 01:48:55 +0100
>> "DypthroposTheImposter"<mcbracket@gmail.com>  wrote:
>>
>>>          See the static_if paper here:
>>>
>>> http://isocpp.org/forums
>>>
>>> Under the post "constraints and static if" there is a link to a
>>> document about
>>> static_if
>>>
>>> https://docs.google.com/viewer?a=v&pid=forums&srcid=MDIyMDc3NjUwMTczOTM0Mjk3NjABMDI2MzM3MjkxNDM4NDQ5MzE4NDcBLWVsS1Y4dFhtdDhKATUBaXNvY3BwLm9yZwF2Mg
>>>
>>>         Are they full of it? Has it caused the problems they mention
>>> in
>>> D?
>>
>> Does that document exist somewhere in a the form of a real web page?
>> Or at least *any* real document format?
>
> To be clear, that's not a veiled attack on anything. I really *am*
> just simply asking if there's a link for that anywhere to a real file
> (html, pdf, text, wordperfect, gif, hell whatever.)
>
I converted it to pdf.  Do you want it?
March 09, 2013
On Saturday, 9 March 2013 at 18:23:29 UTC, 1100110 wrote:
> I love how the second set show up in two different styles on my computer.

This is not different style, this is different chars. << >> != « » .
March 09, 2013
On 03/09/2013 01:48 AM, DypthroposTheImposter wrote:
>         See the static_if paper here:
>
> http://isocpp.org/forums
>
> Under the post "constraints and static if" there is a link to a
> document about
> static_if
>
> https://docs.google.com/viewer?a=v&pid=forums&srcid=MDIyMDc3NjUwMTczOTM0Mjk3NjABMDI2MzM3MjkxNDM4NDQ5MzE4NDcBLWVsS1Y4dFhtdDhKATUBaXNvY3BwLm9yZwF2Mg
>
>
>        Are they full of it?

Maybe. The paper is full of typos.

> Has it caused the problems they mention in D?

All of the non-C++ specific ones that are not made up to make the paper longer. Eg:

0. Templates + static if are an ad-hoc abstraction mechanism.

1. Declaration-site template body type checking becomes undecidable.

2. Constraint-based overloading needs manual work in order to express specialization relations.


In D there also exist other problems that wouldn't occur in C++ in that form:

static if(!is(typeof(x))) enum y = 1;
static if(!is(typeof(y))) enum z = 2;
static if(!is(typeof(z))) enum x = 3;

The above currently does not have any defined behaviour. If the three are distributed to mutually importing modules, which constants get defined may depend on the order the modules are passed to DMD on the command line. (It is solvable, but so far few people have shown interest.)

March 09, 2013
On 03/09/2013 12:30 PM, deadalnix wrote:
> On Saturday, 9 March 2013 at 18:23:29 UTC, 1100110 wrote:
>> I love how the second set show up in two different styles on my computer.
>
> This is not different style, this is different chars. << >> != « » .

Yes, but my email client did not display them( « » ) as the same character.

They showed up as two distinct characters( « >> (we're totally going to pretend that's one character)), which amused me since your comment was "let's do it with style."