Another use-case for multiple alias this

Jonathan M Davis jmdavisProg at gmx.com
Mon Aug 5 15:39:00 PDT 2013


On Monday, August 05, 2013 22:19:49 Andrej Mitrovic wrote:
> And in fact multiple alias this is a feature we've practically all
> agreed on, but what's holding it from being finally implemented?

I would think that the main problem is that someone needs to implement it, but 
there's likely a number of issues relating to how it interacts with 
opDispatch, precendence between the various aliases, etc., all of which will 
need to be ironed out.

I'd _really_ like to have it though, because it'll allow me to fix a design flaw 
in std.datetime. For some reason, I made it so that SimpleTimeZone took its 
UTC offset as a naked integer value and provides it as a naked integer value 
whereas, it really should be a Duration. I've fixed the constructor (or at 
least provided the correct one in addition to the bad one), but I can't fix the 
utcOffset property without breaking code. If I had multiple alias this-es, then 
I could create a Voldemort type which is aliased to both int and Duration, and 
then deprecate the alias to int and thereby provide a migration path away from 
the current bad design. Without multiple alias this-es, I don't know how to 
fix the problem without breaking code - not without doing something like 
renaming the property, which would make it inconsistent with the rest of the 
API. So, I'd _love_ to have multiple alias this-es implemented.

Maybe it's on Kenji's TODO list? IIRC, he's done plenty of other work related 
to opDispatch and alias this in the past several months, so he may be paving 
the way for it.

- Jonathan M Davis


More information about the Digitalmars-d mailing list