[Issue 5467] library-based typedef

2020-03-20 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=5467

Basile-z  changed:

   What|Removed |Added

 CC|b2.t...@gmx.com |

--


[Issue 5467] library-based typedef

2017-01-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=5467

b2.t...@gmx.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||b2.t...@gmx.com
 Resolution|--- |FIXED

--- Comment #5 from b2.t...@gmx.com ---
this should have been closed for a while (std.typecons.TypeDef)

--


[Issue 5467] library-based typedef

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=5467

Andrei Alexandrescu  changed:

   What|Removed |Added

Version|D1 & D2 |D2

--


[Issue 5467] library-based typedef

2012-01-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5467


Robert Clipsham  changed:

   What|Removed |Added

 CC||rob...@octarineparrot.com


--- Comment #4 from Robert Clipsham  2012-01-02 
00:15:40 GMT ---
(In reply to comment #0)
> 1. Something that's just like another type yet "parallel" with it. This is 
> good
> for abstractions that encode different units of measurement that aren't
> supposed to be mixed.
> 
> ParallelTypedef!double Miles;
> 
> Such a type should accept explicit initialization from a regular double:
> 
> auto dist = Miles(3.2);
> 
> However it shouldn't accept initialization from another parallel typedef:
> 
> ParallelTypedef!double Kms;
> auto dist1 = Kms(4);
> auto dist2 = Miles(dist1); // no


This needs a better name, parallel is transitive, so Miles(dist1) should work
(if there are 3 things, A, B and C, A is parallel to B and B is parallel to C,
then A is parallel to C).


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


[Issue 5467] library-based typedef

2012-01-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5467


Stewart Gordon  changed:

   What|Removed |Added

 CC||s...@iname.com


--- Comment #3 from Stewart Gordon  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: ---


[Issue 5467] library-based typedef

2011-12-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5467


Jonathan M Davis  changed:

   What|Removed |Added

 CC||jmdavisp...@gmx.com


--- Comment #2 from Jonathan M Davis  2011-12-30 03:23:17 
PST ---
https://github.com/D-Programming-Language/phobos/pull/300

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


[Issue 5467] library-based typedef

2011-01-20 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5467



--- Comment #1 from Trass3r  2011-01-20 08:51:08 PST ---
And that's the latest code draft I could find:

enum Type
{
Independent,
Super,
Sub,
Parallel,
}

struct Typedef( T, Type type = Type.Sub, T init = T.init, string _f = __FILE__,
int _l = __LINE__ )
{
T payload = init;


static if ( type != Type.Independent )
{
this( T value )
{
payload = value;
}
}
static if ( type == Type.Sub)
{
// typedef int foo; foo f;
// f.opCast!(t)() == cast(t) f
T opCast(T)()
{
return payload;
}
}
static if ( type == Type.Sub || type == Type.Parallel )
{
alias payload this;
}
static if ( type == Type.Super )
{
typeof( this ) opAssign( T value )
{
payload = value;
return this;
}
}
else static if ( type == Type.Sub )
{
@disable void opAssign( T value );
}
}

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