November 23
On Wednesday, 23 November 2022 at 22:16:35 UTC, Guillaume Piolat wrote:
> On Tuesday, 22 November 2022 at 09:37:43 UTC, bauss wrote:
>>
>> If it's not implemented with .identifier then I will oppose it.
>>
>
> +1

So that's two "no" votes to the feature.
November 23
On Tuesday, 22 November 2022 at 19:10:18 UTC, Paul Backus wrote:
>
> Of course, the module scope .identifier syntax is not very widely used in the first place, so maybe a small risk of breakage is worth the benefit of nice syntax for enum members.

.identifier syntax meaning module scope is not especially intuitive.
We got used to it with ::identifier in C++, and it got imported from there.

It could be something explicit like module.identifier


November 23
On Wednesday, 23 November 2022 at 22:25:04 UTC, Guillaume Piolat wrote:
> It could be something explicit like module.identifier

This isn't quite the same as .identifier, since `module.identifier` looks up ident specifically in module, whereas .identifier just bypasses the local name and might refer to a local thing, or in an imported thing.

module foo;
.destroy() // often refers to object.destroy()  rather than foo.destroy()


So it would take a little effort if these things had to be ported.
November 23
On 11/23/2022 8:13 AM, XavierAP wrote:
> But interoperating with C isn't the problem here, because C enums don't map to D enums but to integers?

ImportC maps C enums to D enums.
November 23
On 11/21/2022 5:19 PM, Timon Gehr wrote:
> I guess the two-pass thing is how function literals work, so you'd do that?

Function literals are pretty much treated as templates.


> The DIP does not propose trying all combinations. You'd get number of function overloads copies for each occurrence of $a. It's not exponential and without overloading (I think this is the majority of cases in typical user code) it is one copy.

The combinatorics matter, they can't be done incrementally. But I suggest abandoning the ETI for overloaded functions.
November 24

On Wednesday, 23 November 2022 at 23:53:23 UTC, Walter Bright wrote:

>

On 11/21/2022 5:19 PM, Timon Gehr wrote:

>

I guess the two-pass thing is how function literals work, so you'd do that?

Function literals are pretty much treated as templates.

>

The DIP does not propose trying all combinations. You'd get number of function overloads copies for each occurrence of $a. It's not exponential and without overloading (I think this is the majority of cases in typical user code) it is one copy.

The combinatorics matter, they can't be done incrementally. But I suggest abandoning the ETI for overloaded functions.

Strictly speaking the worst case combinatorics for overloaded $ expressions is O(n * m) where n is the number of overloads, m is the number of distinct enum parameters in the same position.

It's generally as demanding as as other overload resolutions.
It's true that for

int f(EnumType1 e) { return 1; }
int f(EnumType2 e) { return 2; }
int f(EnumType3 e) { return 3; }
pragma(msg, f($a));

There will be at most 3 lookups into the enum member hash table,
to check whether the member a collides.

for

int f(EnumType1 e, EnumType2 e2) { return 1; }
int f(EnumType2 e, EnumType1 e2) { return 2; }
int f(EnumType3 e, EnumType3 e2) { return 3; }
pragma(msg, f($a, $b));

there will be 6 lookups in the worst case, (which is the success case).

And it is possible to make these lookups cheaper than they are right now.

November 24

On Thursday, 24 November 2022 at 10:33:04 UTC, Stefan Koch wrote:

>

Strictly speaking the worst case combinatorics for overloaded $ expressions is O(n * m) where n is the number of overloads, m is the number of distinct enum parameters in the same position.

Oops I used the words strictly speaking, that was wrong.
Because the hash-table lookup could degenerate into a linear search.

strictly speaking: it's O(n * m * k) where
n is the number of overloads
m is the sum of enum parameters in n
k is sum of the number of enum members in the set of distinct enum types used by all overloads.
But that's highly unlikely.

So, generally speaking it's O(n * m).
strictly speaking it's O (n * m * k).

November 24
On Wednesday, 23 November 2022 at 23:50:55 UTC, Walter Bright wrote:
> On 11/23/2022 8:13 AM, XavierAP wrote:
>> But interoperating with C isn't the problem here, because C enums don't map to D enums but to integers?
>
> ImportC maps C enums to D enums.

Ah nice. I didn't know, I'm currently playing with (a version of?) Derelict which binds in a different, more C-like and pointy way.

I'm just worried that the defect of C enums being unqualified/weakly typed caused the workaround/defect of repeating the type name in every value, which when imported into a better enum language like D causes annoyance, which causes some people to wish for enums not requiring qualification to avoid the repetition. Whereas the cause of the repetition is the specific enum declarations (which can be aliased), not the D language. When an enum is properly named without repetition I think it's good that you have to qualify it -- outside possibly the special case of initialization. So did the designers of many modern languages including the C++ committee.

So I still personally think this proposal is a bad idea. 😇
November 24

On Wednesday, 23 November 2022 at 22:22:23 UTC, Adam D Ruppe wrote:

>

On Wednesday, 23 November 2022 at 22:16:35 UTC, Guillaume Piolat wrote:

>

On Tuesday, 22 November 2022 at 09:37:43 UTC, bauss wrote:

>

If it's not implemented with .identifier then I will oppose it.

+1

So that's two "no" votes to the feature.

Not a DIP contributor, but if it's open voting, I like Walter's alternative of no punctuation, if possible. Otherwise I have no particular opinion on which character, .indentifier is fine, but $ feels like I'm writing perl again, not very attractive. :/

Would absolutely use this feature, though. Have similar use cases to ryuukk_'s examples.

November 24
On Thursday, 24 November 2022 at 14:01:27 UTC, XavierAP wrote:
>
> Ah nice. I didn't know, I'm currently playing with (a version of?) Derelict which binds in a different, more C-like and pointy way.
>


I believe Derelict was the old way of binding to C, where as BindBC is the new and modern way.

A lot of the Derelict projects are now deprecated in favor of their BindBC counterpart.