Which Docker to use?

2018-10-16 Thread Ky-Anh Huynh via Digitalmars-d-learn
Hi, I need to build some static binaries with LDC. I also need to execute builds on both platform 32-bit and 64-bit. From Docker Hub there are two image groups: * language/ldc (last update 5 months ago) * dlang2/ldc-ubuntu (updated recently) Which one do you suggest? Thanks a lot.

Re: longjmp [still] crashes on windows?

2018-10-16 Thread tipdbmp via Digitalmars-d-learn
SrMordred had already figured it (setjmp vs _setjmp(..., null)) out: https://forum.dlang.org/post/abrjmdvvlqdmmnpxc...@forum.dlang.org

how to get UDA only for methods

2018-10-16 Thread test via Digitalmars-d-learn
I need get the Route UDA only for method without (static methods, property, constructor, destructor), dont know how to do it. Route[] getRoutes(T)(){ Route[] routes; foreach(int i, m; __traits(allMembers, T) ){ pragma(msg, m.stringof); static

Re: Why doesn't foreach support iterating?

2018-10-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 01:17:40 UTC, Chris Katko wrote: I finally noticed in the docs it says "for arrays only." The question is, why? foreach for user-defined types only allow arguments that match what the user defined. Ranges typically do not define this (since it generally

Why doesn't foreach support iterating?

2018-10-16 Thread Chris Katko via Digitalmars-d-learn
int [50]data; foreach(i, datum; data){} // works File file("gasdgasd"); foreach(i, line; file.byLine){} //NOPE. foreach(line; file.byLine){} //works. I finally noticed in the docs it says "for arrays only." The question is, why? Every language that I used previously (as far as I can

Do D's std.signals check for already-connected slot and simply ignore the call?

2018-10-16 Thread Enjoys Math via Digitalmars-d-learn
If they don't, I have to wrap it like so: import std.signals; class Signal(T) { protected: mixin Signal!(T); }; class Changed(T) : Signal!T { protected: void delegate(T)[] slots; public: override void connect(void delegate(T) slot) { foreach (s; slots) { if (s == slot)

Re: Dealing with ranges where front and popFront do the same logic / eager ranges

2018-10-16 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Oct 16, 2018 at 10:59:50PM +, Dennis via Digitalmars-d-learn wrote: > I've always been curious around the design choice of ranges to make > front and popFront separate functions, instead of having popFront > return the front. I suppose it is useful sometimes to be able to > access

Dealing with ranges where front and popFront do the same logic / eager ranges

2018-10-16 Thread Dennis via Digitalmars-d-learn
I've always been curious around the design choice of ranges to make front and popFront separate functions, instead of having popFront return the front. I suppose it is useful sometimes to be able to access front multiple times without having to save it temporarily (can't think of a specific

Re: Is this a bug?

2018-10-16 Thread Márcio Martins via Digitalmars-d-learn
On Tuesday, 16 October 2018 at 13:09:34 UTC, Steven Schveighoffer wrote: On 10/15/18 4:36 PM, Márcio Martins wrote: [...] Hm... didn't realize that. It seems to me like an odd limitation, but I can see how it's ambiguous. The solution is to double-template: template incx(Args...) {

longjmp [still] crashes on windows?

2018-10-16 Thread tipdbmp via Digitalmars-d-learn
An old thread about the same problem: https://forum.dlang.org/thread/mmxwhdypncaeikknl...@forum.dlang.org struct jmp_buf { byte[256] data; } jmp_buf my_jmp_buf; extern(C) { int setjmp(ref jmp_buf env); void longjmp(ref jmp_buf env, int); } void second() { writefln("second");

Re: Is there a way to use std.regex at compile-time?

2018-10-16 Thread drug via Digitalmars-d-learn
16.10.2018 17:47, cosinus пишет: On Tuesday, 16 October 2018 at 14:42:32 UTC, cosinus wrote: Is there a way to use std.regex at compile-time? I would like to `mixin()` the result of this function: ```D string generateVertexStruct() {     auto reVertex =

Re: Is there a way to use std.regex at compile-time?

2018-10-16 Thread Stefam Koch via Digitalmars-d-learn
On Tuesday, 16 October 2018 at 14:47:19 UTC, cosinus wrote: On Tuesday, 16 October 2018 at 14:42:32 UTC, cosinus wrote: Is there a way to use std.regex at compile-time? I would like to `mixin()` the result of this function: ```D string generateVertexStruct() { auto reVertex =

Re: Reading binary streams with decoding to Unicode

2018-10-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/16/18 11:42 AM, Vinay Sajip wrote: On Monday, 15 October 2018 at 22:49:31 UTC, Nicholas Wilson wrote: Oh, sorry I missed that. Take a look at https://github.com/schveiguy/iopipe Great, thanks. Let me know if anything doesn't work there. The text processing is pretty robust, but

Re: Reading binary streams with decoding to Unicode

2018-10-16 Thread Vinay Sajip via Digitalmars-d-learn
On Monday, 15 October 2018 at 22:49:31 UTC, Nicholas Wilson wrote: Oh, sorry I missed that. Take a look at https://github.com/schveiguy/iopipe Great, thanks.

Re: Is there a way to use std.regex at compile-time?

2018-10-16 Thread cosinus via Digitalmars-d-learn
On Tuesday, 16 October 2018 at 14:42:32 UTC, cosinus wrote: Is there a way to use std.regex at compile-time? I would like to `mixin()` the result of this function: ```D string generateVertexStruct() { auto reVertex = ctRegex!(`in\s+(?P\w+)\s+(?P\w+)\s*;`); const vertexStruct =

Is there a way to use std.regex at compile-time?

2018-10-16 Thread cosinus via Digitalmars-d-learn
Is there a way to use std.regex at compile-time?

Re: Is this a bug?

2018-10-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/15/18 4:36 PM, Márcio Martins wrote: On Monday, 15 October 2018 at 16:46:34 UTC, Steven Schveighoffer wrote: On 10/15/18 12:40 PM, Márcio Martins wrote: import std.stdio; void incx(T, Args...)(ref T t) { ++t.x; } static struct Test(T) { T x; } void main() { Test!uint t;

Re: When does GC run?

2018-10-16 Thread Stanislav Blinov via Digitalmars-d-learn
On Tuesday, 16 October 2018 at 09:38:44 UTC, John Burton wrote: The information I have found indicates that it runs to free memory when the system runs out of memory to allocate. No, that is incorrect. By default, here's what's happening: 1) At startup (or first 'new' or GC.malloc) the GC

Re: is there something like `stm32-rs` in D?

2018-10-16 Thread wiffel via Digitalmars-d-learn
On Wednesday, 26 September 2018 at 08:51:11 UTC, Radu wrote: On Wednesday, 26 September 2018 at 05:55:49 UTC, dangbinghoo wrote: On Wednesday, 26 September 2018 at 05:24:08 UTC, Radu wrote: On Wednesday, 26 September 2018 at 03:46:21 UTC, dangbinghoo wrote: hi,

Re: ref tidy way to defreference or is something else going on ?

2018-10-16 Thread rikki cattermole via Digitalmars-d-learn
On 16/10/2018 11:36 PM, Codifies wrote: I've a bunch of 4x4 matrix routines in C, in order to avoid copying around multiple 4x4 matrices I pass pointers... I'm assuming that in D it would make sense to use ref ? what's going on behind the scenes with ref is it just a nice way of passing

ref tidy way to defreference or is something else going on ?

2018-10-16 Thread Codifies via Digitalmars-d-learn
I've a bunch of 4x4 matrix routines in C, in order to avoid copying around multiple 4x4 matrices I pass pointers... I'm assuming that in D it would make sense to use ref ? what's going on behind the scenes with ref is it just a nice way of passing pointers with automagical dereferencing or is

Re: Access violation connecting a signal / slot

2018-10-16 Thread Enjoys Math via Digitalmars-d-learn
Solved: I forgot to initialize some member variable along the way, which is a class so needed to be new'd. Thanks.

Re: When does GC run?

2018-10-16 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 16 October 2018 at 09:38:44 UTC, John Burton wrote: Is there any documentation or information about the specifics of the garbage collector? The information I have found indicates that it runs to free memory when the system runs out of memory to allocate. But will this try to use

Re: When does GC run?

2018-10-16 Thread rikki cattermole via Digitalmars-d-learn
On 16/10/2018 10:38 PM, John Burton wrote: Is there any documentation or information about the specifics of the garbage collector? The information I have found indicates that it runs to free memory when the system runs out of memory to allocate. But will this try to use all the system memory

When does GC run?

2018-10-16 Thread John Burton via Digitalmars-d-learn
Is there any documentation or information about the specifics of the garbage collector? The information I have found indicates that it runs to free memory when the system runs out of memory to allocate. But will this try to use all the system memory or some other amount before trying to

Re: Is there an efficient byte buffer queue?

2018-10-16 Thread John Burton via Digitalmars-d-learn
On Sunday, 14 October 2018 at 13:07:30 UTC, Heromyth wrote: On Monday, 8 October 2018 at 09:39:55 UTC, John Burton wrote: My use case is sending data to a socket. We have ported some containers from JAVA. ByteBuffer is a basic container interface and widely used in JAVA. See also:

Access violation connecting a signal / slot

2018-10-16 Thread Enjoys Math via Digitalmars-d-learn
I have a class or struct (have tried both; same error): module track_changes; import std.array; import std.signals; class TrackChanges(T) { private: T[] _stack; int _current = 0; public: mixin Signal!(T); TrackChanges opAssign(TrackChanges x) { this = x(); return

Re: Is this a bug?

2018-10-16 Thread Kagamin via Digitalmars-d-learn
You can simply group them: t.on!( handlers!( "abc", { writeln("abc"); }, "cde", { writeln("cde"); } ) ); handlers!( "abc", { writeln("abc"); }, "cde", { writeln("cde"); } ).bind(t);

Re: Is this a bug?

2018-10-16 Thread Márcio Martins via Digitalmars-d-learn
On Tuesday, 16 October 2018 at 02:13:21 UTC, Ali Çehreli wrote: On 10/15/2018 01:36 PM, Márcio Martins wrote: > Considering that the declaration is legal, and that the template > parameter deduction works when Args.length == 0, but stops working when > Args.length > 0. For deduction to work,