Re: Phobos func for string -> enum member?

2016-10-13 Thread Nick Sabalausky via Digitalmars-d-learn
On 10/13/2016 07:14 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Oct 13, 2016 at 07:11:15PM -0400, Nick Sabalausky via Digitalmars-d-learn wrote: I'm sure it'd be easy enough to write, but does phobos have a simple way to convert the name of an enum member from a runtime string to the

Re: Phobos func for string -> enum member?

2016-10-13 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Oct 13, 2016 at 07:11:15PM -0400, Nick Sabalausky via Digitalmars-d-learn wrote: > I'm sure it'd be easy enough to write, but does phobos have a simple > way to convert the name of an enum member from a runtime string to the > enum type? > > Ie, something like: > > enum Foobar { foo=1,

Re: Phobos func for string -> enum member?

2016-10-13 Thread Ali Çehreli via Digitalmars-d-learn
On 10/13/2016 04:11 PM, Nick Sabalausky wrote: I'm sure it'd be easy enough to write, but does phobos have a simple way to convert the name of an enum member from a runtime string to the enum type? Ie, something like: enum Foobar { foo=1, bar } Foobar a = doesThisExistInPhobos!Foobar("foo");

Phobos func for string -> enum member?

2016-10-13 Thread Nick Sabalausky via Digitalmars-d-learn
I'm sure it'd be easy enough to write, but does phobos have a simple way to convert the name of an enum member from a runtime string to the enum type? Ie, something like: enum Foobar { foo=1, bar } Foobar a = doesThisExistInPhobos!Foobar("foo"); I'm not finding anything like it in the docs,

Re: Building DMD with DMD or LDC

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 13 October 2016 at 19:28:11 UTC, Daniel Kozak wrote: You can easy try it. Just build dmd with dmd, than with ldc. And then try to compile DMD frontend with both dmd versions :) Dne 13.10.2016 v 21:07 Nordlöw via Digitalmars-d-learn napsal(a): Is there a large speed difference in

Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 13 October 2016 at 19:11:36 UTC, Adam D. Ruppe wrote: Try `-defaultlib=libphobos2.so` with your dmd command line. The .so version is pic compiled. Building DMD fails to how do I modify the call make -f posix.mak under the dmd checkout?

Re: ReturnType and Parameters of Templated function/method

2016-10-13 Thread Patric Dexheimer via Digitalmars-d-learn
On Thursday, 13 October 2016 at 21:07:17 UTC, ketmar wrote: On Thursday, 13 October 2016 at 20:52:09 UTC, Patric Dexheimer wrote: So for now my idea is to brute force the numbers of arguments with 'compiles' trait or trying to get the sourcecode somehow. depending on source code form (even if

Re: ReturnType and Parameters of Templated function/method

2016-10-13 Thread ketmar via Digitalmars-d-learn
On Thursday, 13 October 2016 at 20:52:09 UTC, Patric Dexheimer wrote: So for now my idea is to brute force the numbers of arguments with 'compiles' trait or trying to get the sourcecode somehow. depending on source code form (even if you can get it) is highly error-prone. consider it UB.

Re: Illegal behaviour or GDC bug?

2016-10-13 Thread ketmar via Digitalmars-d-learn
On Thursday, 13 October 2016 at 20:22:51 UTC, Peter Campbell wrote: OK that's cool, I'll just avoid GDC for now. Is it generally a good approach to assume if something compiles in DMD then it's correct and just hope that GDC/LDC pick up the latest version at some point? mostly yes. btw, ldc

Re: ReturnType and Parameters of Templated function/method

2016-10-13 Thread Patric Dexheimer via Digitalmars-d-learn
On Thursday, 13 October 2016 at 18:01:25 UTC, Ali Çehreli wrote: On 10/13/2016 07:19 AM, Patric Dexheimer wrote: There is a way to capture the return type/parameters of a templated function like: void add(T)(T t){} Parameters!add; Yes, i know that the template don´t have any type until

Batch compilation and -unittest flag

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
Is there a way to call dmd/rdmd on a set of files but only activate unittest for one of them? This would significantly cut down my wait times when developing D in Emacs with flycheck-d-unittest: https://github.com/flycheck/flycheck-d-unittest Without it I have to implement my own build

Re: Illegal behaviour or GDC bug?

2016-10-13 Thread Peter Campbell via Digitalmars-d-learn
On Thursday, 13 October 2016 at 20:18:31 UTC, ketmar wrote: sadly, gdc has way older frontend version than ldc (and dmd, of course). gdc is like 2.067, and ldc/dmd is 2.072. that this was fixed in later versions, but gdc is not updated yet. OK that's cool, I'll just avoid GDC for now. Is it

Re: Illegal behaviour or GDC bug?

2016-10-13 Thread ketmar via Digitalmars-d-learn
sadly, gdc has way older frontend version than ldc (and dmd, of course). gdc is like 2.067, and ldc/dmd is 2.072. that this was fixed in later versions, but gdc is not updated yet.

Illegal behaviour or GDC bug?

2016-10-13 Thread Peter Campbell via Digitalmars-d-learn
Good evening all, I'm just starting to learn D and I've been experimenting with some template stuff as well as checking out DMD, GDC and LDC. During my experimentation I found a piece of code that doesn't compile in GDC but does compile in DMD and LDC. The code snippet can be found here:

Re: Building DMD with DMD or LDC

2016-10-13 Thread Daniel Kozak via Digitalmars-d-learn
You can easy try it. Just build dmd with dmd, than with ldc. And then try to compile DMD frontend with both dmd versions :) Dne 13.10.2016 v 21:07 Nordlöw via Digitalmars-d-learn napsal(a): Is there a large speed difference in compilation time depending on whether the DMD used is built using

Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10

2016-10-13 Thread Adam D. Ruppe via Digitalmars-d-learn
Try `-defaultlib=libphobos2.so` with your dmd command line. The .so version is pic compiled. Or you can recompile the whole lib.

Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 13 October 2016 at 18:35:43 UTC, Matthias Klumpp wrote: The new toolchains of Ubuntu (and Debian soon too) default to PIE code, so in order to link correctly, the project needs to be compiled with PIE/PIC to work. So how do I do this? Instructions? Can I bootstrap DMD or do I

Building DMD with DMD or LDC

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
Is there a large speed difference in compilation time depending on whether the DMD used is built using DMD or LDC?

Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 13 October 2016 at 19:01:55 UTC, Nordlöw wrote: Can I bootstrap DMD or do I need to cross-compile to the new PIE/PIC? Is this what AUTO_BOOTSTRAP=1 is for and what does it do?

Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10

2016-10-13 Thread Matthias Klumpp via Digitalmars-d-learn
On Thursday, 13 October 2016 at 17:07:19 UTC, Nordlöw wrote: On Thursday, 13 October 2016 at 17:02:32 UTC, Nordlöw wrote: Am I using the wrong GCC version? Should I use GCC 5 instead? GCC 6.2 is default on 16.10. Compiling DMD with GCC 5 as make -f posix.mak HOST_CXX=g++-5 also fails with

Re: ReturnType and Parameters of Templated function/method

2016-10-13 Thread Ali Çehreli via Digitalmars-d-learn
On 10/13/2016 07:19 AM, Patric Dexheimer wrote: There is a way to capture the return type/parameters of a templated function like: void add(T)(T t){} Parameters!add; Yes, i know that the template don´t have any type until explicitly coded like: Parameters!(add!int); Or another solution like

Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 13 October 2016 at 17:02:32 UTC, Nordlöw wrote: Am I using the wrong GCC version? Should I use GCC 5 instead? GCC 6.2 is default on 16.10. Compiling DMD with GCC 5 as make -f posix.mak HOST_CXX=g++-5 also fails with same errors.

Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
I just upgraded my Ubuntu to 16.10 and now my rebuilding of dmd from git master fails as /usr/bin/ld: idgen.o: relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld:

Re: Rust-like collect in D

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 13 October 2016 at 10:00:56 UTC, Nordlöw wrote: For instance, we can use `if (!isInfinite!Range)` to forbid collecting values from an infinite `Range`. Is this checking done? That is `0.iota.make!Array` should not be allowed. https://github.com/dlang/phobos/pull/4860

Re: Current State of the GC?

2016-10-13 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 13 October 2016 at 11:55:50 UTC, Jonathan M Davis wrote: On Monday, October 10, 2016 21:12:42 Martin Lundgren via Digitalmars-d-learn wrote: I've been reading up a bit on the D garbage collector. Seen mostly negative things about it. I've also seen a lot of proposals and what not,

ReturnType and Parameters of Templated function/method

2016-10-13 Thread Patric Dexheimer via Digitalmars-d-learn
There is a way to capture the return type/parameters of a templated function like: void add(T)(T t){} Parameters!add; Yes, i know that the template don´t have any type until explicitly coded like: Parameters!(add!int); Or another solution like getting the string function declaration will

Re: Current State of the GC?

2016-10-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 10, 2016 21:12:42 Martin Lundgren via Digitalmars-d-learn wrote: > I've been reading up a bit on the D garbage collector. Seen > mostly negative things about it. I've also seen a lot of > proposals and what not, but not much about the current state of > things. > > The latest