Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 27, 2007 Inadequacies of __traits | ||||
---|---|---|---|---|
| ||||
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 |
July 27, 2007 Re: Inadequacies of __traits | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirk McDonald | 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) |
July 27, 2007 Re: Inadequacies of __traits | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | 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 |
July 27, 2007 Re: Inadequacies of __traits | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirk McDonald | 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.
|
July 27, 2007 Re: Inadequacies of __traits | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kirk McDonald | "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. |
Copyright © 1999-2021 by the D Language Foundation