www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is binding to alias a definite superset of binding to a type

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
This seems to be an overlook:

https://issues.dlang.org/show_bug.cgi?id=20863

Are there any non-bug cases showing different treatment of type 
parameters vs. alias parameters? I mean:

template xyz(T) { ... }

vs.

template xyz(alias T) { ... }

The second should "catch" everything the first does, and more.
May 25
next sibling parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Monday, 25 May 2020 at 20:58:56 UTC, Andrei Alexandrescu wrote:
 This seems to be an overlook:

 https://issues.dlang.org/show_bug.cgi?id=20863

 Are there any non-bug cases showing different treatment of type 
 parameters vs. alias parameters? I mean:

 template xyz(T) { ... }

 vs.

 template xyz(alias T) { ... }

 The second should "catch" everything the first does, and more.
It used to be the case that alias parameters could not bind basic types. Because they are not symbols. However I gather that this issue has been "worked around" Therefore, an alias would bind to almost anything. including any type.
May 25
parent reply Max Samukha <maxsamukha gmail.com> writes:
On Monday, 25 May 2020 at 21:13:10 UTC, Stefan Koch wrote:
 On Monday, 25 May 2020 at 20:58:56 UTC, Andrei Alexandrescu 
 wrote:
 This seems to be an overlook:

 https://issues.dlang.org/show_bug.cgi?id=20863

 Are there any non-bug cases showing different treatment of 
 type parameters vs. alias parameters? I mean:

 template xyz(T) { ... }

 vs.

 template xyz(alias T) { ... }

 The second should "catch" everything the first does, and more.
It used to be the case that alias parameters could not bind basic types. Because they are not symbols. However I gather that this issue has been "worked around" Therefore, an alias would bind to almost anything. including any type.
Why can't basic types just be made symbols? They are symbols in more consistent languages (such as Haskell), where they are implicitly declared in a built-in namespace.
May 26
next sibling parent Stefan Koch <uplink.coder googlemail.com> writes:
On Tuesday, 26 May 2020 at 11:33:04 UTC, Max Samukha wrote:
 On Monday, 25 May 2020 at 21:13:10 UTC, Stefan Koch wrote:
 On Monday, 25 May 2020 at 20:58:56 UTC, Andrei Alexandrescu 
 wrote:
 This seems to be an overlook:

 https://issues.dlang.org/show_bug.cgi?id=20863

 Are there any non-bug cases showing different treatment of 
 type parameters vs. alias parameters? I mean:

 template xyz(T) { ... }

 vs.

 template xyz(alias T) { ... }

 The second should "catch" everything the first does, and more.
It used to be the case that alias parameters could not bind basic types. Because they are not symbols. However I gather that this issue has been "worked around" Therefore, an alias would bind to almost anything. including any type.
Why can't basic types just be made symbols? They are symbols in more consistent languages (such as Haskell), where they are implicitly declared in a built-in namespace.
There is no fundamental reason (as far as I can see at least) why they couldn't be.
May 26
prev sibling parent reply Meta <jared771 gmail.com> writes:
On Tuesday, 26 May 2020 at 11:33:04 UTC, Max Samukha wrote:
 On Monday, 25 May 2020 at 21:13:10 UTC, Stefan Koch wrote:
 On Monday, 25 May 2020 at 20:58:56 UTC, Andrei Alexandrescu 
 wrote:
 This seems to be an overlook:

 https://issues.dlang.org/show_bug.cgi?id=20863

 Are there any non-bug cases showing different treatment of 
 type parameters vs. alias parameters? I mean:

 template xyz(T) { ... }

 vs.

 template xyz(alias T) { ... }

 The second should "catch" everything the first does, and more.
It used to be the case that alias parameters could not bind basic types. Because they are not symbols. However I gather that this issue has been "worked around" Therefore, an alias would bind to almost anything. including any type.
Why can't basic types just be made symbols? They are symbols in more consistent languages (such as Haskell), where they are implicitly declared in a built-in namespace.
It's a moot point since alias template parameters now accept built in types.
May 26
parent reply Max Samukha <maxsamukha gmail.com> writes:
On Tuesday, 26 May 2020 at 16:04:17 UTC, Meta wrote:

 It's a moot point since alias template parameters now accept 
 built in types.
Yes, with a ton of hacks in the implementation, I presume.
May 26
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Tuesday, 26 May 2020 at 16:16:26 UTC, Max Samukha wrote:
 On Tuesday, 26 May 2020 at 16:04:17 UTC, Meta wrote:

 It's a moot point since alias template parameters now accept 
 built in types.
Yes, with a ton of hacks in the implementation, I presume.
No it was a one line change. DMD is much better and handling wired ASTs than you give it credit for. The overload resolution was changed to accept types on the matching level convert That's it.
May 26
parent Max Samukha <maxsamukha gmail.com> writes:
On Tuesday, 26 May 2020 at 18:49:05 UTC, Stefan Koch wrote:

 No it was a one line change.
 DMD is much better and handling wired ASTs than you give it 
 credit for.
 The overload resolution was changed to accept types on the 
 matching level convert
 That's it.
Then I need to shut up and look at the code.
May 26
prev sibling parent Nick Treleaven <nick geany.org> writes:
On Monday, 25 May 2020 at 20:58:56 UTC, Andrei Alexandrescu wrote:
 This seems to be an overlook:

 https://issues.dlang.org/show_bug.cgi?id=20863
I made a pull to remove unnecessary overloads in std.meta, and ran into this bug. Maybe you found it doing the same? https://github.com/dlang/phobos/pull/7513
Jun 04