digitalmars.D.learn - Get constructor for a class
- simendsjo (2/2) Sep 13 2013 allMembers returns "this", but trying to get "this" or "__ctor"
- Gary Willoughby (5/7) Sep 13 2013 foreach (func; __traits(getOverloads, T, "__ctor"))
- simendsjo (8/16) Sep 13 2013 Thanks.
- Gary Willoughby (6/23) Sep 13 2013 A lot of the traits stuff is very confusing, i think a lot of it
- simendsjo (9/36) Sep 13 2013 I know what you mean. Have been using quite some __traits and
- H. S. Teoh (23/33) Sep 13 2013 [...]
- Namespace (10/61) Sep 13 2013 We should clean up this mess in 'is' and 'traits' and especially
- simendsjo (11/32) Sep 13 2013 (...)
- Namespace (5/38) Sep 13 2013 Not...?
- Jacob Carlborg (5/7) Sep 14 2013 DMD breaks code in every single release. All 2.05x and 2.06x releases
- simendsjo (8/16) Sep 14 2013 I know each release breaks code in various ways, but if 2.064 was
allMembers returns "this", but trying to get "this" or "__ctor" using getMember fails. Is there any way to get this method?
Sep 13 2013
On Friday, 13 September 2013 at 09:12:53 UTC, simendsjo wrote:allMembers returns "this", but trying to get "this" or "__ctor" using getMember fails. Is there any way to get this method?foreach (func; __traits(getOverloads, T, "__ctor")) { ... }
Sep 13 2013
On Friday, 13 September 2013 at 13:16:12 UTC, Gary Willoughby wrote:On Friday, 13 September 2013 at 09:12:53 UTC, simendsjo wrote:Thanks. Still a bit strange though.. "this" is always a member for classes, but if there's only an implicit ctor, only "this" exists, and getOverloads "__ctor" fails. If there exists explicit ctors on the other hand, both "this" *and* "__ctor" exists.allMembers returns "this", but trying to get "this" or "__ctor" using getMember fails. Is there any way to get this method?foreach (func; __traits(getOverloads, T, "__ctor")) { ... }
Sep 13 2013
On Friday, 13 September 2013 at 13:31:34 UTC, simendsjo wrote:On Friday, 13 September 2013 at 13:16:12 UTC, Gary Willoughby wrote:A lot of the traits stuff is very confusing, i think a lot of it is still being finalised and in development. I'm working on a project using a lot of traits stuff and it's doing my head in. I wish there was better documentation. e.g. what is 'func' in the code above? i'm using it successfully but i've no idea what it is.On Friday, 13 September 2013 at 09:12:53 UTC, simendsjo wrote:Thanks. Still a bit strange though.. "this" is always a member for classes, but if there's only an implicit ctor, only "this" exists, and getOverloads "__ctor" fails. If there exists explicit ctors on the other hand, both "this" *and* "__ctor" exists.allMembers returns "this", but trying to get "this" or "__ctor" using getMember fails. Is there any way to get this method?foreach (func; __traits(getOverloads, T, "__ctor")) { ... }
Sep 13 2013
On Friday, 13 September 2013 at 14:02:15 UTC, Gary Willoughby wrote:On Friday, 13 September 2013 at 13:31:34 UTC, simendsjo wrote:I know what you mean. Have been using quite some __traits and is(), and I still have to look up the syntax for is() all the time, and experiment with both trying to find the edge-cases. My biggest problem is that there's only one possible context pointer for templates and that often DMD is unable to use contexts even though they are mixed in at the call-site and really should be available...On Friday, 13 September 2013 at 13:16:12 UTC, Gary Willoughby wrote:A lot of the traits stuff is very confusing, i think a lot of it is still being finalised and in development. I'm working on a project using a lot of traits stuff and it's doing my head in. I wish there was better documentation. e.g. what is 'func' in the code above? i'm using it successfully but i've no idea what it is.On Friday, 13 September 2013 at 09:12:53 UTC, simendsjo wrote:Thanks. Still a bit strange though.. "this" is always a member for classes, but if there's only an implicit ctor, only "this" exists, and getOverloads "__ctor" fails. If there exists explicit ctors on the other hand, both "this" *and* "__ctor" exists.allMembers returns "this", but trying to get "this" or "__ctor" using getMember fails. Is there any way to get this method?foreach (func; __traits(getOverloads, T, "__ctor")) { ... }
Sep 13 2013
On Fri, Sep 13, 2013 at 04:16:30PM +0200, simendsjo wrote:On Friday, 13 September 2013 at 14:02:15 UTC, Gary Willoughby wrote:[...][...] The syntax for is() is one gigantic mess. It does work, but it's not pretty. IIRC Walter admitted that it could do with some cleanup, but it's a bit too late now since too much code relies on its quirks. As for __traits, I believe the intention was that it wasn't meant for end-user consumption, but for Phobos to be able to access compiler internals. As such, it only provides the bare minimum for Phobos to be able to work, so there are a lot of quirks and edge cases. I was quite dismayed yesterday to discover that "parameter type tuples" are actually different from the usual "type tuples", and don't even behave consistently with foreach (they masquerade as type tuples w.r.t. foreach, and there's weird special-casing for 1-element slices of them, e.g. for __traits(identifier...)). I don't know what's the rationale for this strange design, but it sure looks like it was just a quick hack to make Phobos work rather than anything carefully thought out. Personally, I would just stick with the Phobos interfaces, and file bugs (or pull requests) if the existing interfaces aren't sufficient for your needs. T -- Let X be the set not defined by this sentence...A lot of the traits stuff is very confusing, i think a lot of it is still being finalised and in development. I'm working on a project using a lot of traits stuff and it's doing my head in. I wish there was better documentation. e.g. what is 'func' in the code above? i'm using it successfully but i've no idea what it is.I know what you mean. Have been using quite some __traits and is(), and I still have to look up the syntax for is() all the time, and experiment with both trying to find the edge-cases.
Sep 13 2013
On Friday, 13 September 2013 at 15:16:36 UTC, H. S. Teoh wrote:On Fri, Sep 13, 2013 at 04:16:30PM +0200, simendsjo wrote:We should clean up this mess in 'is' and 'traits' and especially for tuples. IMO it's ok if it breaks code as long as it helps to write cleaner and tough code. This will also help D to gain more attention. There is so many crap in D... We should really start to clean up as long as D2 is still a Beta. And we should stop to transform it into something like C++ with transferring built-in features into the library (like scope or delete).On Friday, 13 September 2013 at 14:02:15 UTC, Gary Willoughby wrote:[...][...] The syntax for is() is one gigantic mess. It does work, but it's not pretty. IIRC Walter admitted that it could do with some cleanup, but it's a bit too late now since too much code relies on its quirks. As for __traits, I believe the intention was that it wasn't meant for end-user consumption, but for Phobos to be able to access compiler internals. As such, it only provides the bare minimum for Phobos to be able to work, so there are a lot of quirks and edge cases. I was quite dismayed yesterday to discover that "parameter type tuples" are actually different from the usual "type tuples", and don't even behave consistently with foreach (they masquerade as type tuples w.r.t. foreach, and there's weird special-casing for 1-element slices of them, e.g. for __traits(identifier...)). I don't know what's the rationale for this strange design, but it sure looks like it was just a quick hack to make Phobos work rather than anything carefully thought out. Personally, I would just stick with the Phobos interfaces, and file bugs (or pull requests) if the existing interfaces aren't sufficient for your needs. TA lot of the traits stuff is very confusing, i think a lot of it is still being finalised and in development. I'm working on a project using a lot of traits stuff and it's doing my head in. I wish there was better documentation. e.g. what is 'func' in the code above? i'm using it successfully but i've no idea what it is.I know what you mean. Have been using quite some __traits and is(), and I still have to look up the syntax for is() all the time, and experiment with both trying to find the edge-cases.
Sep 13 2013
On Friday, 13 September 2013 at 15:27:42 UTC, Namespace wrote:On Friday, 13 September 2013 at 15:16:36 UTC, H. S. Teoh wrote:(...)On Fri, Sep 13, 2013 at 04:16:30PM +0200, simendsjo wrote:On Friday, 13 September 2013 at 14:02:15 UTC, Gary Willoughby wrote:[...](...)The syntax for is() is one gigantic mess. It does work, but it's not pretty. IIRC Walter admitted that it could do with some cleanup, but it's a bit too late now since too much code relies on its quirks.We should clean up this mess in 'is' and 'traits' and especially for tuples. IMO it's ok if it breaks code as long as it helps to write cleaner and tough code. This will also help D to gain more attention. There is so many crap in D... We should really start to clean up as long as D2 is still a Beta. And we should stop to transform it into something like C++ with transferring built-in features into the library (like scope or delete).D2 is in beta...? I agree is() and __traits is quite messy, and I have quite some workarounds for various stuff in the combination of is() __traits(), alias, enum and templates - basically generic programming. But I doubt many people here agree D2 is in beta and will allow breaking existing code in ways that changing the aforementioned features would do.
Sep 13 2013
On Friday, 13 September 2013 at 22:10:02 UTC, simendsjo wrote:On Friday, 13 September 2013 at 15:27:42 UTC, Namespace wrote:Not...? It's far away from final. o.O If D2 is final I tend to leave this scene... It more broken than C++ ever was.On Friday, 13 September 2013 at 15:16:36 UTC, H. S. Teoh wrote:(...)On Fri, Sep 13, 2013 at 04:16:30PM +0200, simendsjo wrote:On Friday, 13 September 2013 at 14:02:15 UTC, Gary Willoughby wrote:[...](...)The syntax for is() is one gigantic mess. It does work, but it's not pretty. IIRC Walter admitted that it could do with some cleanup, but it's a bit too late now since too much code relies on its quirks.We should clean up this mess in 'is' and 'traits' and especially for tuples. IMO it's ok if it breaks code as long as it helps to write cleaner and tough code. This will also help D to gain more attention. There is so many crap in D... We should really start to clean up as long as D2 is still a Beta. And we should stop to transform it into something like C++ with transferring built-in features into the library (like scope or delete).D2 is in beta...? I agree is() and __traits is quite messy, and I have quite some workarounds for various stuff in the combination of is() __traits(), alias, enum and templates - basically generic programming. But I doubt many people here agree D2 is in beta and will allow breaking existing code in ways that changing the aforementioned features would do.
Sep 13 2013
On 2013-09-14 00:10, simendsjo wrote:But I doubt many people here agree D2 is in beta and will allow breaking existing code in ways that changing the aforementioned features would do.DMD breaks code in every single release. All 2.05x and 2.06x releases have caused code breakage for DWT in some way or another. -- /Jacob Carlborg
Sep 14 2013
On Saturday, 14 September 2013 at 11:00:26 UTC, Jacob Carlborg wrote:On 2013-09-14 00:10, simendsjo wrote:I know each release breaks code in various ways, but if 2.064 was to redesign is() and __traits() without maintaining backwards compability I think many people would fork/leave D altogether. So I'm not sure if I would call it beta even if each release breaks code due to bugs, bugfixes, removing code that shouldn't be allowed i the first place etc.But I doubt many people here agree D2 is in beta and will allow breaking existing code in ways that changing the aforementioned features would do.DMD breaks code in every single release. All 2.05x and 2.06x releases have caused code breakage for DWT in some way or another.
Sep 14 2013
On Saturday, 14 September 2013 at 11:29:33 UTC, simendsjo wrote:On Saturday, 14 September 2013 at 11:00:26 UTC, Jacob Carlborg wrote:Then tell me, what do you call it then? final? ;)On 2013-09-14 00:10, simendsjo wrote:I know each release breaks code in various ways, but if 2.064 was to redesign is() and __traits() without maintaining backwards compability I think many people would fork/leave D altogether. So I'm not sure if I would call it beta even if each release breaks code due to bugs, bugfixes, removing code that shouldn't be allowed i the first place etc.But I doubt many people here agree D2 is in beta and will allow breaking existing code in ways that changing the aforementioned features would do.DMD breaks code in every single release. All 2.05x and 2.06x releases have caused code breakage for DWT in some way or another.
Sep 14 2013
On Saturday, 14 September 2013 at 11:45:38 UTC, Namespace wrote:On Saturday, 14 September 2013 at 11:29:33 UTC, simendsjo wrote:I've been waiting it to be final since 2007 :) Getting better by leaps and bounds though.On Saturday, 14 September 2013 at 11:00:26 UTC, Jacob Carlborg wrote:Then tell me, what do you call it then? final? ;)On 2013-09-14 00:10, simendsjo wrote:I know each release breaks code in various ways, but if 2.064 was to redesign is() and __traits() without maintaining backwards compability I think many people would fork/leave D altogether. So I'm not sure if I would call it beta even if each release breaks code due to bugs, bugfixes, removing code that shouldn't be allowed i the first place etc.But I doubt many people here agree D2 is in beta and will allow breaking existing code in ways that changing the aforementioned features would do.DMD breaks code in every single release. All 2.05x and 2.06x releases have caused code breakage for DWT in some way or another.
Sep 14 2013
On Saturday, 14 September 2013 at 13:14:50 UTC, simendsjo wrote:On Saturday, 14 September 2013 at 11:45:38 UTC, Namespace wrote:But still a long long way. :)On Saturday, 14 September 2013 at 11:29:33 UTC, simendsjo wrote:I've been waiting it to be final since 2007 :) Getting better by leaps and bounds though.On Saturday, 14 September 2013 at 11:00:26 UTC, Jacob Carlborg wrote:Then tell me, what do you call it then? final? ;)On 2013-09-14 00:10, simendsjo wrote:I know each release breaks code in various ways, but if 2.064 was to redesign is() and __traits() without maintaining backwards compability I think many people would fork/leave D altogether. So I'm not sure if I would call it beta even if each release breaks code due to bugs, bugfixes, removing code that shouldn't be allowed i the first place etc.But I doubt many people here agree D2 is in beta and will allow breaking existing code in ways that changing the aforementioned features would do.DMD breaks code in every single release. All 2.05x and 2.06x releases have caused code breakage for DWT in some way or another.
Sep 14 2013