[Issue 5467] library-based typedef

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 1 13:50:18 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=5467


Stewart Gordon <smjg at iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg at iname.com


--- Comment #3 from Stewart Gordon <smjg at iname.com> 2012-01-01 13:50:10 PST ---
(In reply to comment #0)
> ParallelTypdef!(double, "allow_arithmetic", "allow_mixed:*,/,%")
>     Miles;

This leaves much to be desired: we want to allow Miles * double but not Miles *
Miles, and Miles + Miles but not Miles + double.  Moreover, Miles / Miles wants
to return double.

Maybe we need a more specialised version of ParallelTypedef that does primitive
units checking.  opMul and opDiv would themselves be templates therein.  Maybe
I'll have a go at implementing something when I have a bit more time....

> 2. Opaque "handle" types that can be used with overloading. The base type of
> the typedef is just the storage strategy:

So it's basically a struct wrapper.

> 3. Proper subtype. Create a true subtype of a type that allows explicit
> initialization from the type and implicit conversion to the type.

This seems the closest to how typedefs behave at the moment.

> 4. Proper supertype. The base type implicitly converts to the introduced type,
> but not vice versa.

Makes sense, but I'm not sure what practical it would have....

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list