November 16, 2009
Andrei Alexandrescu wrote:
> Ellery Newcomer wrote:
>> Andrei Alexandrescu wrote:
>>> Ellery Newcomer wrote:
>>>> KennyTM~ wrote:
>>>>> throw ...;
>>>>> assert(...);
>>>>>
>>>> you can call functions which do these...
>>> ... which is where the "none"/"bottom" type comes into play!
>>>
>>> Andrei
>>
>> What what?
> 
> http://en.wikipedia.org/wiki/Bottom_type http://www.cs.washington.edu/research/projects/cecil/www/Release/doc-cecil-stdlib/node4.html
> 
> 
> I gave a talk about similar stuff once but I don't know where it is. I also have 70% of an article on it written (and with a funny introduction to boot) but I couldn't find the time * interest to finish.
> 
> 
> Andrei

So a function that always throws should have a result type (maximal
type?) of bottom type?
November 16, 2009
Ellery Newcomer wrote:
> Andrei Alexandrescu wrote:
>> Ellery Newcomer wrote:
>>> Andrei Alexandrescu wrote:
>>>> Ellery Newcomer wrote:
>>>>> KennyTM~ wrote:
>>>>>> throw ...;
>>>>>> assert(...);
>>>>>>
>>>>> you can call functions which do these...
>>>> ... which is where the "none"/"bottom" type comes into play!
>>>>
>>>> Andrei
>>> What what?
>> http://en.wikipedia.org/wiki/Bottom_type
>> http://www.cs.washington.edu/research/projects/cecil/www/Release/doc-cecil-stdlib/node4.html
>>
>>
>> I gave a talk about similar stuff once but I don't know where it is. I
>> also have 70% of an article on it written (and with a funny introduction
>> to boot) but I couldn't find the time * interest to finish.
>>
>>
>> Andrei
> 
> So a function that always throws should have a result type (maximal
> type?) of bottom type?

Yah, because it never actually returns. Functions like abort() or exit() would return bottom in a type system that supports it.

Andrei
November 17, 2009
grauzone wrote:
> Walter Bright wrote:
>> Reminds me a bit of D a few years back, when people would say D didn't have lambda's. But D did have them! The problem was the syntax was a bit verbose. Simplified the syntax, and suddenly the lambda's got noticed and got used.
> 
> D has no tuples.

I see what you did there.
November 17, 2009
Walter Bright wrote:
> Don wrote:
>> That's not fall-through, one case is *inside* the 'if' clause of another one!! Wow. Do you really want to encourage that sort of thing?
> 
> I think it's more the #if that obfuscates the code. After long experience with #if, I really don't like it, which is why I adamantly resist having fine-grained conditional compilation in D.

I'm used to that. If you take out the #if, it's still wierd. That one really ought to be a goto. It's the presence of the 'else' in particular:

case A:
     if (xxx)
     {
case B:
        yyy;
     }
     else
     {
        zzz;
     }
     break;

I had to read it several times before I could make sense of it. Although the zzz; looks like it's part of the B case, it's only part of the A case.

An oddity is that this compiles:

  switch(x) {
case 1:
     if (x<10)
Lcase2:
        writefln("yyy");
     else
        writefln("zzz");
     break;
     }

and so does this:

  switch(x) {
case 1:
     if (x<10)
case 2:
        writefln("yyy");
  }

but this doesn't:

  switch(x) {
case 1:
     if (x<10)
case 2:
        writefln("yyy");
     else
        writefln("zzz");
     break;
  }
1 2 3 4 5 6 7 8
Next ›   Last »