Re: Can I create static c callable library?

2018-09-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/27/18 8:16 AM, Atila Neves wrote: On Tuesday, 25 September 2018 at 14:13:50 UTC, Jacob Carlborg wrote: On Tuesday, 25 September 2018 at 12:05:21 UTC, Jonathan M Davis wrote: If you use -betterC, then it's trivial, because your D program is restricted to extern(C) functions and features

Re: Can I create static c callable library?

2018-09-27 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 27, 2018 at 09:48:50PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Thursday, 27 September 2018 at 21:41:31 UTC, H. S. Teoh wrote: > > Though I'm not sure what will happen if your C program tries loading > > two or more D libraries that use this trick... is rt_init() > >

Re: Can I create static c callable library?

2018-09-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 September 2018 at 21:41:31 UTC, H. S. Teoh wrote: Though I'm not sure what will happen if your C program tries loading two or more D libraries that use this trick... is rt_init() idempotent? It just refcounts itself.

Re: Can I create static c callable library?

2018-09-27 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 27, 2018 at 03:11:26PM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: > On Thursday, September 27, 2018 6:16:13 AM MDT Atila Neves via Digitalmars- > d-learn wrote: [...] > > Even easier, compile this C file and add the resulting object > > file to your (now mostly) D static

Re: Can I create static c callable library?

2018-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 27, 2018 6:16:13 AM MDT Atila Neves via Digitalmars- d-learn wrote: > On Tuesday, 25 September 2018 at 14:13:50 UTC, Jacob Carlborg > > wrote: > > On Tuesday, 25 September 2018 at 12:05:21 UTC, Jonathan M Davis > > > > wrote: > >> If you use -betterC, then it's trivial,

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Chad Joan via Digitalmars-d-learn
On Thursday, 27 September 2018 at 09:58:25 UTC, Jonathan M Davis wrote: For two types to be compared, they must be the the same type - or they must be implicitly convertible to the same type, in which case, they're converted to that type and then compared. So, as far as D's design of

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Chad Joan via Digitalmars-d-learn
On Thursday, 27 September 2018 at 13:23:15 UTC, Adam D. Ruppe wrote: On Thursday, 27 September 2018 at 05:04:09 UTC, Chad Joan wrote: As above, I think this might be a very clean and effective solution for a different class of use-cases :) I'll keep it in mind though. Yeah. And I did make

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Chad Joan via Digitalmars-d-learn
On Thursday, 27 September 2018 at 14:23:48 UTC, Steven Schveighoffer wrote: On 9/27/18 10:20 AM, Steven Schveighoffer wrote: typeid sometimes gives you a more derived type than TypeInfo. Including for classes and structs. In the past, .classinfo gave you a different thing than typeid(obj),

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Chad Joan via Digitalmars-d-learn
On Thursday, 27 September 2018 at 13:16:58 UTC, Adam D. Ruppe wrote: On Thursday, 27 September 2018 at 05:18:14 UTC, Chad Joan wrote: How does this work? The language reference states that typeid(Type) returns "an instance of class TypeInfo corresponding to Type".

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Chad Joan via Digitalmars-d-learn
On Thursday, 27 September 2018 at 18:37:27 UTC, Chad Joan wrote: I will probably end up going with the latter suggestion and have Extended use the Root's T. That would probably make sense for what I'm doing. In my case, the T allows the caller to configure what kind of output the thing

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Chad Joan via Digitalmars-d-learn
On Thursday, 27 September 2018 at 08:56:22 UTC, Alex wrote: On Wednesday, 26 September 2018 at 20:41:38 UTC, Chad Joan wrote: class Root(T) { T x; } class Extended(T) : Root!T { T y; } Sorry for a technical aside, but would this be something for you?

vibe.d error

2018-09-27 Thread hridyansh thakur via Digitalmars-d-learn
i've tried both on linux and windows whenever i try to start a vibe.d project , it fails while running DUB giving exist status one on both , here is the thing linux: hridyansh@dilawar-PC:~/d/web$ dub vibe-core 1.4.3: building configuration "epoll"...

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/27/18 10:20 AM, Steven Schveighoffer wrote: typeid sometimes gives you a more derived type than TypeInfo. Including for classes and structs. In the past, .classinfo gave you a different thing than typeid(obj), but now it is the same thing:     auto obj = new Object;     // classinfo

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/27/18 1:18 AM, Chad Joan wrote: On Wednesday, 26 September 2018 at 21:25:07 UTC, Steven Schveighoffer wrote: ... Object.factory is a really old poorly supported type of reflection. I would not depend on it for anything. Roger that.  Will avoid :) You are better off using your own

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 September 2018 at 05:04:09 UTC, Chad Joan wrote: The tree nodes are potentially very diverse, but the tree structure itself will be very homogeneous. The virtual method can still handle that case! But, if your child array of expressions is already accessible through the base

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 September 2018 at 05:18:14 UTC, Chad Joan wrote: How does this work? The language reference states that typeid(Type) returns "an instance of class TypeInfo corresponding to Type". (https://dlang.org/spec/expression.html#typeid_expressions) But then the TypeInfo class doesn't

Re: Can I create static c callable library?

2018-09-27 Thread Atila Neves via Digitalmars-d-learn
On Tuesday, 25 September 2018 at 14:13:50 UTC, Jacob Carlborg wrote: On Tuesday, 25 September 2018 at 12:05:21 UTC, Jonathan M Davis wrote: If you use -betterC, then it's trivial, because your D program is restricted to extern(C) functions and features which don't require druntime. It can

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 27, 2018 2:44:25 AM MDT Chad Joan via Digitalmars-d- learn wrote: > The spec seems to have the homogeneous cases covered: classes > with classes or structs with structs. What I'm more worried > about is stuff like when you have a class compared to a struct or > builtin

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Alex via Digitalmars-d-learn
On Wednesday, 26 September 2018 at 20:41:38 UTC, Chad Joan wrote: class Root(T) { T x; } class Extended(T) : Root!T { T y; } Sorry for a technical aside, but would this be something for you? https://forum.dlang.org/post/vtaxcxpufrovwfrkb...@forum.dlang.org I mean... In

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Chad Joan via Digitalmars-d-learn
On Thursday, 27 September 2018 at 08:19:41 UTC, Jonathan M Davis wrote: On Thursday, September 27, 2018 1:41:23 AM MDT Chad Joan via Digitalmars-d- learn wrote: On Thursday, 27 September 2018 at 05:12:06 UTC, Jonathan M Davis This is also reminding me of how it's always bugged me that there

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 27, 2018 1:41:23 AM MDT Chad Joan via Digitalmars-d- learn wrote: > On Thursday, 27 September 2018 at 05:12:06 UTC, Jonathan M Davis > This is also reminding me of how it's always bugged me that there > isn't a way to operator overload opEquals with a static method > (or

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Chad Joan via Digitalmars-d-learn
On Thursday, 27 September 2018 at 05:12:06 UTC, Jonathan M Davis wrote: On Wednesday, September 26, 2018 10:20:58 PM MDT Chad Joan via Digitalmars- d-learn wrote: ... That's interesting! Thanks for mentioning. If you don't mind, what are the complaints regarding Object? Or can you link me