June 26, 2013
On Tue, 25 Jun 2013 19:09:26 -0400, Brian Schott <briancschott@gmail.com> wrote:

> On Tuesday, 25 June 2013 at 21:31:15 UTC, Walter Bright wrote:
>> http://wiki.dlang.org/DIP42
>
> The proposal doesn't include suggested changes to the language grammar specification.

Considering the state of the grammar, I don't know if it is critical for the process.

BUT, I would suggest we should include grammar proposals with language proposals. Especially from the language author.

-Steve
June 26, 2013
This raises the parallel question of:
  alias A(T) = expression;

Which I think is equally common as the enum case described here?


On 26 June 2013 07:31, Walter Bright <newshound2@digitalmars.com> wrote:

> http://wiki.dlang.org/DIP42
>


June 26, 2013
2013/6/26 Walter Bright <newshound2@digitalmars.com>

> On 6/25/2013 2:33 PM, Andrej Mitrovic wrote:
>
>> On Tuesday, 25 June 2013 at 21:31:15 UTC, Walter Bright wrote:
>>
>>> http://wiki.dlang.org/DIP42
>>>
>>
>> I suppose the alias version will work too? IOW:
>>
>> alias Select(size_t idx, T...) = T[idx];
>>
>> static assert(is(Select!(0, int, float) == int));
>> static assert(is(Select!(1, int, float) == float));
>>
>
> That's something separate.
>

I don't think so. DIP42 should consider alias version, from the grammatical view.

enum basically takes an expression,

  enum E(T) = expression;

But alias should take a type grammatically.

  alias A(T) = type;


And one more question: How template constraint will be written?

  enum E(T) if (isSomething!T) = expression;   // is this supposed?

Kenji Hara


June 26, 2013
26.06.2013 1:31, Walter Bright пишет:
> http://wiki.dlang.org/DIP42

What about enhancement 7364 [1] (from [2] discussion)?

As we still have such cases:
---
static if (...)
    enum fullyQualifiedNameImplForTypes = ...;
else static if (...)
    enum fullyQualifiedNameImplForTypes = ...;
else static if (...)
    ...
---
which will look better this way:
---
static if (...)
    enum template = ...;
else static if (...)
    enum template = ...;
else ...
---

Also note current syntax is error-prone as one can easily make a typo or copy paste mistake which will lead to cryptic template errors.

[1] http://d.puremagic.com/issues/show_bug.cgi?id=7364
[2] http://forum.dlang.org/thread/jfh7po$3b$1@digitalmars.com?page=1


-- 
Денис В. Шеломовский
Denis V. Shelomovskij
June 26, 2013
On 6/26/13, Denis Shelomovskij <verylonglogin.reg@gmail.com> wrote:
> which will look better this way:
> ---
> static if (...)
>      enum template = ...;
> else static if (...)
>      enum template = ...;
> else ...
> ---

Yeah I agree, this is more important than DIP42's shortened syntax for simple templates. It's the more complicated templates that are the problem.
June 26, 2013
On 06/25/2013 11:31 PM, Walter Bright wrote:
> http://wiki.dlang.org/DIP42

The answer to life, the universe and everything? :-)

June 29, 2013
26.06.2013 20:35, Andrej Mitrovic пишет:
> On 6/26/13, Denis Shelomovskij <verylonglogin.reg@gmail.com> wrote:
>> which will look better this way:
>> ---
>> static if (...)
>>       enum template = ...;
>> else static if (...)
>>       enum template = ...;
>> else ...
>> ---
>
> Yeah I agree, this is more important than DIP42's shortened syntax for
> simple templates. It's the more complicated templates that are the
> problem.
>

It's rather strange that enhancement 7364 isn't implemented yet (and even not discussed) as it's an easy-to-implement change with big pros and no cons.

-- 
Денис В. Шеломовский
Denis V. Shelomovskij
June 29, 2013
I've been wondering if we could have parameterized named enumS. The syntax for it would look somewhat similar:

enum Fruit(T) : T { apple, banana = -42 }

void main()
{
    auto shortFruit = Fruit!(short).apple;
    auto longFruit  = Fruit!(long).banana;

    longFruit = shortFruit; // OK: implicit conversion allowed
    shortFruit = longFruit; // OK: ... even a truncating one

    Fruit!uint uintFruit; // Error: -42 is out of range of uint
    Fruit!string stringFruit; // Error: enums need initializers
}
July 20, 2013
Posted pull request: https://github.com/D-Programming-Language/dmd/pull/2368

Kenji Hara


2013/6/26 Walter Bright <newshound2@digitalmars.com>

> http://wiki.dlang.org/DIP42
>


July 20, 2013
Kenji Hara:

> Posted pull request:
> https://github.com/D-Programming-Language/dmd/pull/2368

Is implementing that better than implementing issue 7364?

Bye,
bearophile