Inability to dup/~ for const arrays of class objects
Michel Fortin
michel.fortin at michelf.ca
Wed Jun 12 06:13:47 PDT 2013
On 2013-06-11 23:24:56 +0000, "Daniel Murphy" <yebblies at nospamgmail.com> said:
> What does const(C) matching (T : const(U), U) give?
>
> If we follow what arrays and pointers do, it removes one level of const,
> giving:
> const(C) : const(U)
> U == const(C)ref
Exactly. That works.
> If you then match with (T : const(U)ref, U)
>
> You get the 'ref' suffix removed, giving const(C), then one level of const
> removed, giving:
> const(C)ref
>
> This is the problem I hit with template deduction. It is possible to define
> the matching differently for classes... but the problem comes from the 'ref'
> suffix being optional.
If you can manage to patch DMD as you suggest, then it'll be
theoretically more sound and there's chances the resulting code in the
compiler (at the semantic level at least) will be cleaner than what I
did, so I'm all for it.
I fail to see how getting a "non-reference" type for the class (through
U in this template) would be useful though. You can't use that type
directly, all you can do is add a 'ref' after it.
My fear is that you'll just move some weird behaviour from the semantic
to the syntactic level. You'll have a true reference type that'll be
implicitly there but optional at the same time. Well, maybe. That's
just a feeling I have. By all means, give it a try so we know how it
fares.
--
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca/
More information about the Digitalmars-d
mailing list