www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Inadequacies of __traits

reply Kirk McDonald <kirklin.mcdonald gmail.com> writes:
I started writing this as a newsgroup post, but decided I'd rather make 
it a blog post:

http://kirkmcdonald.blogspot.com/2007/07/inadequacies-of-traits.html

__traits is a worthy addition to D, but it needs a couple more features 
to be truly useful.

-- 
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org
Jul 27 2007
next sibling parent reply BCS <ao pathlink.com> writes:
Reply to Kirk,

 I started writing this as a newsgroup post, but decided I'd rather
 make it a blog post:
 
 http://kirkmcdonald.blogspot.com/2007/07/inadequacies-of-traits.html
 
 __traits is a worthy addition to D, but it needs a couple more
 features to be truly useful.
 
I'd post this as a comment but, I don't have a Google account. off the cuff ctor might be usable like this: (cast(Foo)(new byte[Foo.sizeOfObject]).ptr)._ctor(100)
Jul 27 2007
parent reply Kirk McDonald <kirklin.mcdonald gmail.com> writes:
BCS wrote:
 Reply to Kirk,
 
 I started writing this as a newsgroup post, but decided I'd rather
 make it a blog post:

 http://kirkmcdonald.blogspot.com/2007/07/inadequacies-of-traits.html

 __traits is a worthy addition to D, but it needs a couple more
 features to be truly useful.
I'd post this as a comment but, I don't have a Google account. off the cuff ctor might be usable like this: (cast(Foo)(new byte[Foo.sizeOfObject]).ptr)._ctor(100)
The primary issue I have with with _ctor is that you cannot use it to get the signatures of all of the class's constructors (just of the lexically first constructor). My second concern is that the isFooFunction traits don't report what kind of function it is correctly. -- Kirk McDonald http://kirkmcdonald.blogspot.com Pyd: Connecting D and Python http://pyd.dsource.org
Jul 27 2007
parent BCS <ao pathlink.com> writes:
Reply to Kirk,

 The primary issue I have with with _ctor is that you cannot use it to
 get the signatures of all of the class's constructors (just of the
 lexically first constructor). My second concern is that the
 isFooFunction traits don't report what kind of function it is
 correctly.
 
I'm basically with you on this. _ctor is to different than the rest to be thrown in there. Maybe it needs it's own trait, some sort of __traits(ctorOf, Foo) that gives a tuple of signatures.
Jul 27 2007
prev sibling parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Kirk McDonald" <kirklin.mcdonald gmail.com> wrote in message 
news:f8drd0$1i92$1 digitalmars.com...
I started writing this as a newsgroup post, but decided I'd rather make it 
a blog post:

 http://kirkmcdonald.blogspot.com/2007/07/inadequacies-of-traits.html

 __traits is a worthy addition to D, but it needs a couple more features to 
 be truly useful.
Doesn't really help your problem, but just a bit of info to make the constructor issue a little more lucid. The constructor really is just another class method. Class construction works something like (1) allocate the class's memory, either using the default method or using the overloaded 'new', (2) copy the static instance of the class into that memory, and (3) call the _ctor method of the new instance. That's why (1) you can call _ctor as an instance method and (2) it returns 'this', as returning 'this' is why "new Foo()" gives you the instance -- you're really getting the return value of _ctor. But more on topic, hopefully Walter will be receptive to your comments this time too.
Jul 27 2007