April 04, 2014
On Fri, Apr 04, 2014 at 20:11:39 +0000, John Colvin wrote:
> unicode decoding. front decodes a code-point from a string instead of
> a code-unit (single char)

Another reason for separating 'byte' and 'char' types?

--Ben
April 05, 2014
On 2014-04-04 04:31, Walter Bright wrote:
> On 4/3/2014 7:19 PM, bearophile wrote:
>> I have asked for fully typesafe enums in D,
>
> You can do this:
>
>     struct MyInt {
>         int x;
>         alias this x;
>         ... put your various constraints here ...
>     }
>
> to get typesafe enums. In fact, you can use this construct to create a
> type that overrides selected behaviors of any other type.

For a more complete implementation of typesafe enums, here's my take:

https://github.com/Biotronic/Collectanea/blob/master/biotronic/enumeration.d

--
  Simen
April 05, 2014
bearophile, el  4 de April a las 18:39 me escribiste:
> Walter Bright:
> 
> Thank you for the answers.
> 
> >Here's one:
> >
> >  enum Index { A, B, C }
> >  T[Index.max] array; // Error: Index.max is not an int
> >  ...
> >  array[B] = t;   // Error: B is not an int
> 
> In the last months I've grown a moderate desire for optionally strongly typed array indexes in D (as seen in Ada, but with a

What about:

enum Int : int { One = 1, Two, Three } // implicitly casteable to int
enum Symbolic { Dogs, Cars, Trees }    // not implicitly casteable (and
				       // maybe not even expose the
				       // internal value)

?

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
April 05, 2014
On Friday, 4 April 2014 at 01:54:16 UTC, Ben Boeckel wrote:
> There is *zero* rationale as to why this would be a compilable
> implementation of comparison:
>
>     int compare(int a, int b) {
>         return a * b;
>     }
>
> The fact that this compiles when used as a comparison is *insane* when
> you take a fresh look at how you can construct a language.

You're actually not restricted to int; you can also return float, or in fact any type that's compare to 0, including user-defined types that implement their own `opCmp`.
April 05, 2014
On 04/03/2014 04:45 AM, Walter Bright wrote:
> On 4/2/2014 6:55 PM, Andrei Alexandrescu wrote:
>> A lot of them could apply to us as well.
>>
>> https://www.youtube.com/watch?v=TS1lpKBMkgg
>
>
> at about 44:00: "I begged them not to do them [AST macros]." :-)

(This is a misquote.)
April 05, 2014
On 4/5/2014 2:40 AM, Leandro Lucarella wrote:
> enum Symbolic { Dogs, Cars, Trees }    // not implicitly casteable (and
> 				       // maybe not even expose the
> 				       // internal value)
>
> ?


struct Symbolic {
    private static struct _impl { private int x; }
    enum Dogs = _impl(0);
    enum Cars = _impl(1);
    enum Trees = _impl(2);
}

Of course, you can hide all this in a template.
April 05, 2014
On 4/5/2014 10:10 AM, Timon Gehr wrote:
> On 04/03/2014 04:45 AM, Walter Bright wrote:
>> On 4/2/2014 6:55 PM, Andrei Alexandrescu wrote:
>>> A lot of them could apply to us as well.
>>>
>>> https://www.youtube.com/watch?v=TS1lpKBMkgg
>>
>>
>> at about 44:00: "I begged them not to do them [AST macros]." :-)
>
> (This is a misquote.)

Yeah, I should have been more accurate.

In response to a question about macros & reflection:

"I begged them not to, not to just export the compiler to I begged them I begged them not to do it."
April 05, 2014
On Saturday, 5 April 2014 at 18:47:50 UTC, Walter Bright wrote:
> In response to a question about macros & reflection:
>
> "I begged them not to, not to just export the compiler to I begged them I begged them not to do it."

A reboot is in progress on this, too:
http://scalareflect.org
April 06, 2014
Walter Bright, el  5 de April a las 11:04 me escribiste:
> On 4/5/2014 2:40 AM, Leandro Lucarella wrote:
> >enum Symbolic { Dogs, Cars, Trees }    // not implicitly casteable (and
> >				       // maybe not even expose the
> >				       // internal value)
> >
> >?
> 
> 
> struct Symbolic {
>     private static struct _impl { private int x; }
>     enum Dogs = _impl(0);
>     enum Cars = _impl(1);
>     enum Trees = _impl(2);
> }
> 
> Of course, you can hide all this in a template.

Well, you can "emulate" enums as they are now with structs too, so that doesn't change anything in the argument about why to provide syntax sugar for one and not the other.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
April 06, 2014
On 4/5/2014 6:28 PM, Leandro Lucarella wrote:
> Walter Bright, el  5 de April a las 11:04 me escribiste:
>> Of course, you can hide all this in a template.
>
> Well, you can "emulate" enums as they are now with structs too, so that
> doesn't change anything in the argument about why to provide syntax
> sugar for one and not the other.


The argument for syntactic sugar is it must show a very large benefit over using a template.

Having special syntax for everything makes the language unusable.