Does `is` expression with template alias need fixing.
FeepingCreature
feepingcreature at gmail.com
Wed Mar 22 09:22:01 UTC 2023
On Wednesday, 22 March 2023 at 07:25:04 UTC, Elfstone wrote:
> I wouldn't call what I want a new feature, but a fix to this
> big hole in the language design (or implementation). People
> would expect an alias works the same as the original symbol, at
> least people need not care if they are using an alias from std
> (`Regex`), as long as the compiler will generate a warning
> where an alias might cause problems.
Well, an alias works *the same as the original symbol,* that's
rather the problem. You can't infer the template instantiation
that produced the alias, because the compiler doesn't see the
alias after the fact, because "an alias member" is not a lexical
member in the same way that "a templated struct" is.
My opinion is that we're several steps into an X-Y problem here,
where what we *actually want* is to indicate that a value
fulfills a certain constraint - "is a vector" - in a more
freeform fashion than template constraints allow us to, without
having to write lots of `isVector` type predicates, in a way
that's legible to the typesystem. I think something like type
traits or typeclasses would fulfill this need in a cleaner way
and also make a lot of range code better.
More information about the Digitalmars-d
mailing list