First Draft: Implicit Conversion of Template Instantiations
Dukc
ajieskola at gmail.com
Sat Mar 16 22:28:54 UTC 2024
On Saturday, 16 March 2024 at 15:50:27 UTC, Walter Bright wrote:
> https://github.com/WalterBright/documents/blob/9dba63a4c2887bdb2b988c354ebb0d6bb44c4968/templatecast.md
Thanks. Having a look:
> But `const X!(int*)` will instantiate `bar` as `void bar(int*)`.
Nope. It will instantiate it as `void bar(int*) const`.
> The template struct or template class will be treated as a list
> of its members.
Three points.
1. Why wouldn't this apply only to templated structs? It'd make
sense for the rules to apply to all structs/classes.
2. In the presented example, no fields are actually converted.
The only field, `x`, is the same type in both cases
(`const(int[])`). Please add an example where type of the
field(s) differ, say converting `X!(immutable(int))` to
`const(X!int)`.
3. Could allowing these casts break assumptions of a type that
has `@system` fields (DIP1035)? I haven't thought it deeply
enough to conclude one way pr another but the DIP should probably
explain it.
> Only members that are fields or non-static functions are
> considered.
I don't see why member functions would need to be considered,
static or no. An instance of a struct doesn't contain it's member
functions as fields.
More information about the dip.development
mailing list