Re: How would you create this construct?

2018-03-30 Thread Chris Katko via Digitalmars-d-learn
On Friday, 30 March 2018 at 03:14:42 UTC, Mike Parker wrote: On Friday, 30 March 2018 at 02:30:01 UTC, Chris Katko wrote: [...] Something like this? = import std.stdio; [...] This is beautiful. I mean, the struct stuff looks complicated/non-intuitive at first, but it's all

Re: Fast GC allocation of many small objects

2018-03-30 Thread Alexandru Jercaianu via Digitalmars-d-learn
On Friday, 30 March 2018 at 23:09:33 UTC, Alexandru Jercaianu wrote: On Friday, 30 March 2018 at 20:46:43 UTC, Per Nordlöw wrote: On Friday, 30 March 2018 at 20:38:35 UTC, rikki cattermole wrote: Use a custom allocator (that could be backed by the GC) using std.experimental.allocators :)

Re: Fast GC allocation of many small objects

2018-03-30 Thread Alexandru Jercaianu via Digitalmars-d-learn
On Friday, 30 March 2018 at 20:46:43 UTC, Per Nordlöw wrote: On Friday, 30 March 2018 at 20:38:35 UTC, rikki cattermole wrote: Use a custom allocator (that could be backed by the GC) using std.experimental.allocators :) https://dlang.org/phobos/std_experimental_allocator.html is massive. I

Re: Fast GC allocation of many small objects

2018-03-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/03/2018 9:46 AM, Per Nordlöw wrote: On Friday, 30 March 2018 at 20:38:35 UTC, rikki cattermole wrote: Use a custom allocator (that could be backed by the GC) using std.experimental.allocators :) https://dlang.org/phobos/std_experimental_allocator.html is massive. I guess I should

Re: Fix transposed ranges

2018-03-30 Thread Cym13 via Digitalmars-d-learn
On Friday, 30 March 2018 at 20:43:09 UTC, Cym13 wrote: Hi, I've got the following code that takes a list of files as argument and xor them together (demo example sufficient for that discussion). [...] Forgot to mention but I'm also quite annoyed at the need for that ".array" because

Re: Fast GC allocation of many small objects

2018-03-30 Thread Per Nordlöw via Digitalmars-d-learn
On Friday, 30 March 2018 at 20:38:35 UTC, rikki cattermole wrote: Use a custom allocator (that could be backed by the GC) using std.experimental.allocators :) https://dlang.org/phobos/std_experimental_allocator.html is massive. I guess I should allocate my nodes using auto node =

Fix transposed ranges

2018-03-30 Thread Cym13 via Digitalmars-d-learn
Hi, I've got the following code that takes a list of files as argument and xor them together (demo example sufficient for that discussion). import std.stdio; import std.array; import std.range; import std.algorithm; auto rawContent(string path) { return

Re: Fast GC allocation of many small objects

2018-03-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/03/2018 9:31 AM, Per Nordlöw wrote: I'm working on a graph database with tens of millions of small nodes containing typically around 8-64 bytes of member data. Is there a faster way of allocating many small class objects such as class Node {     // abstract members } class StrNode :

Fast GC allocation of many small objects

2018-03-30 Thread Per Nordlöw via Digitalmars-d-learn
I'm working on a graph database with tens of millions of small nodes containing typically around 8-64 bytes of member data. Is there a faster way of allocating many small class objects such as class Node { // abstract members } class StrNode : Node { string value; } // more

Re: How to customize vibe.data.json

2018-03-30 Thread kerdemdemir via Digitalmars-d-learn
On Friday, 30 March 2018 at 17:58:23 UTC, Seb wrote: On Friday, 30 March 2018 at 16:47:52 UTC, kerdemdemir wrote: Hi, In vibe's web page(http://vibed.org/api/vibe.data.json/serializeToJson) it is told that I should implement [...] I think you are looking for this -

Re: How to customize vibe.data.json

2018-03-30 Thread kerdemdemir via Digitalmars-d-learn
On Friday, 30 March 2018 at 17:58:23 UTC, Seb wrote: On Friday, 30 March 2018 at 16:47:52 UTC, kerdemdemir wrote: Hi, In vibe's web page(http://vibed.org/api/vibe.data.json/serializeToJson) it is told that I should implement [...] I think you are looking for this -

Re: How to customize vibe.data.json

2018-03-30 Thread Seb via Digitalmars-d-learn
On Friday, 30 March 2018 at 16:47:52 UTC, kerdemdemir wrote: Hi, In vibe's web page(http://vibed.org/api/vibe.data.json/serializeToJson) it is told that I should implement [...] I think you are looking for this - https://github.com/vibe-d/vibe.d/pull/2088 Feel free to ping the people

How to customize vibe.data.json

2018-03-30 Thread kerdemdemir via Digitalmars-d-learn
Hi, In vibe's web page(http://vibed.org/api/vibe.data.json/serializeToJson) it is told that I should implement Json toJson() const; static T fromJson(Json src); string toString() const; static T fromString(string src); I think I should implement those as member functions(I am not sure).

Re: dynamically compile and load glue logic

2018-03-30 Thread rikki cattermole via Digitalmars-d-learn
On 31/03/2018 3:38 AM, H. S. Teoh wrote: On Fri, Mar 30, 2018 at 02:24:45PM +, yawniek via Digitalmars-d-learn wrote: in how far is it or would the following be possible: dynamically compile and execute some glue logic that is also written in D under linux? and what happens if that code

Re: dynamically compile and load glue logic

2018-03-30 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 30, 2018 at 02:24:45PM +, yawniek via Digitalmars-d-learn wrote: > in how far is it or would the following be possible: > > dynamically compile and execute some glue logic that is also written > in D under linux? > > and what happens if that code uses phobos or other dub libs

dynamically compile and load glue logic

2018-03-30 Thread yawniek via Digitalmars-d-learn
in how far is it or would the following be possible: dynamically compile and execute some glue logic that is also written in D under linux? and what happens if that code uses phobos or other dub libs that are available in the host binary? especially the 2nd point is important as i would

Re: Initializing a class member that is an object

2018-03-30 Thread Laurent Tréguier via Digitalmars-d-learn
On Friday, 30 March 2018 at 11:14:32 UTC, ketmar wrote: please, make an ER in bugzilla then. 'cause it will be lost here, and with ER we have a chance to eventually do that. Will do.

Re: Initializing a class member that is an object

2018-03-30 Thread ketmar via Digitalmars-d-learn
Laurent Tréguier wrote: On Friday, 30 March 2018 at 11:04:59 UTC, ketmar wrote: p.s.: still, it may be nice to warn user about that. 'cause such runtime initializations are really belong to static ctor. dunno, i'm ok both with warning and without it. I simply think a word about it in the

Re: Initializing a class member that is an object

2018-03-30 Thread Laurent Tréguier via Digitalmars-d-learn
On Friday, 30 March 2018 at 11:04:59 UTC, ketmar wrote: p.s.: still, it may be nice to warn user about that. 'cause such runtime initializations are really belong to static ctor. dunno, i'm ok both with warning and without it. I simply think a word about it in the docs would be nice, since

Re: Link-time optimisation (LTO)

2018-03-30 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 30 March 2018 at 10:23:15 UTC, Cecil Ward wrote: Say that I use say GDC or LDC. I want to declare a routine as public in one compilation unit (.d src file) and be able to access it from other compilation units. Do I simply declare the routine with the word keyword public before

Re: Initializing a class member that is an object

2018-03-30 Thread ketmar via Digitalmars-d-learn
p.s.: still, it may be nice to warn user about that. 'cause such runtime initializations are really belong to static ctor. dunno, i'm ok both with warning and without it.

Re: Initializing a class member that is an object

2018-03-30 Thread ketmar via Digitalmars-d-learn
Laurent Tréguier wrote: Is this behavior really intentional ? yes. default values should be the same for all objects. it is predictable, and allows to initialize objects to the known state simply by blitting `.init`. that is, default values aren't a syntax sugar for defining implicit ctor

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-30 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 16:42:23 UTC, Johan Engelen wrote: On Tuesday, 27 March 2018 at 22:10:33 UTC, Per Nordlöw wrote: On Tuesday, 27 March 2018 at 22:00:42 UTC, Johan Engelen wrote: Indeed. Please try to manually link first (without dub) by modifying the command on which dub errors:

Initializing a class member that is an object

2018-03-30 Thread Laurent Tréguier via Digitalmars-d-learn
Coming from a more Java-esque background, I'm used to sometimes initializing class members outside of the constructor : class MyClass { Object member = new Object(); } I've tried using this in D, but I've come to realize it acts very differently. In Java, the `new Object()` will be

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-30 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 29 March 2018 at 08:44:21 UTC, Jacob Carlborg wrote: Please read the reply :), although it could be a bit more clear. I'll spell it out for you. Both `dflags` and `lflags` are being used already. With separate compilation and linking, there seems to be no way to pass flags to

Link-time optimisation (LTO)

2018-03-30 Thread Cecil Ward via Digitalmars-d-learn
Say that I use say GDC or LDC. I want to declare a routine as public in one compilation unit (.d src file) and be able to access it from other compilation units. Do I simply declare the routine with the word keyword public before the usual declaration? Or maybe that is the default, like not