Re: ref for (const) variables

2015-03-18 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 17 March 2015 at 18:14:48 UTC, Jonathan M Davis wrote: How long is the ref returned by getFoo even valid? Maybe it refers to memory that gets freed on the next line. The compiler can't know. The problem is not specific to variables, any reference type has that issue.

Re: Do strings with enum allocate at usage point?

2015-03-18 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 17 Mar 2015 11:25:00 -0700 Ali Çehreli via Digitalmars-d-learn wrote: > On 03/17/2015 11:21 AM, "岩倉 澪" wrote: > > I often hear it advised to avoid using enum with arrays because they > > will allocate at the usage point, but does this also apply to > > strings? strings are arrays, so nai

Re: Understanding behavior of member functions loaded at runtime

2015-03-18 Thread Kagamin via Digitalmars-d-learn
You violate the ABI, try to use delegates instead of functions.

Temple templates with vibe.d support and first D experiences

2015-03-18 Thread István Zólyomi
Hi, I've been lurking around in the forums for quite a long time now, but only recently tried D for a bit more than some trivial experimentation. Though the documentation of external libraries and the tooling itself is far from a commercial solution in quality, I understand that it's a commun

Re: Do strings with enum allocate at usage point?

2015-03-18 Thread via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 07:58:58 UTC, Daniel Kozák wrote: But is it document somewhere by spec? Or it is just an optimalization which could be remove at some point? I cannot find it in the specification, but it is guaranteed. It's a benefit we get from the immutability of strings. AFAI

Re: Do strings with enum allocate at usage point?

2015-03-18 Thread bearophile via Digitalmars-d-learn
岩倉 澪: However, if enum implies allocation at the usage point for strings, There are two ways to see if something allocates: there is a compiler switch, and an annotation: void foo() @nogc { // Your code here } If the compiler doesn't have a bug it will complain if you put something th

Re: Temple templates with vibe.d support and first D experiences

2015-03-18 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 08:13:37 UTC, István Zólyomi wrote: Hi, I've been lurking around in the forums for quite a long time now, but only recently tried D for a bit more than some trivial experimentation. Though the documentation of external libraries and the tooling itself is far fro

Re: Temple templates with vibe.d support and first D experiences

2015-03-18 Thread István Zólyomi
which dmd version? I'm using DMD64 D Compiler v2.066.0 with DUB version 0.9.22 and I've got the following dependencies in my dub.json: "dependencies": { "vibe-d": "~>0.7.19", "temple": "~>0.7.3" }

variadic mixin - the right tool for the job?

2015-03-18 Thread Robert M. Münch via Digitalmars-d-learn
Hi, can something like this (I borrowed the C pre-processor idea) be done with variadic mixins? #define log(variadic-arg) sys-log("%s:%s" + variadic-arg[0], __FILE__, __LINE__, variadic-arg[1..$]); I read that mixins can only be used for declarations, and this here is a function call. So wo

Re: variadic mixin - the right tool for the job?

2015-03-18 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 18 Mar 2015 15:35:03 +0100 "Robert M. Münch via Digitalmars-d-learn" wrote: > Hi, can something like this (I borrowed the C pre-processor idea) be > done with variadic mixins? > > #define log(variadic-arg) sys-log("%s:%s" + variadic-arg[0], > __FILE__, __LINE__, variadic-arg[1..$]); >

Should this work: export extern(C) auto ...

2015-03-18 Thread Robert M. Münch via Digitalmars-d-learn
Windows, 32-Bit, DLL: export extern(C) struct1 struct1(){ struct1 x; return(x); } export extern(C) auto struct2(){ struct1 x; return(x); } struct1 is visible in the DLL, struct2 is not visible in the DLL. -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: Understanding behavior of member functions loaded at runtime

2015-03-18 Thread Maeriden via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 07:57:39 UTC, Kagamin wrote: You violate the ABI, try to use delegates instead of functions. I'm sorry,I don't understand what you mean.

Re: Temple templates with vibe.d support and first D experiences

2015-03-18 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 13:44:39 UTC, István Zólyomi wrote: which dmd version? I'm using DMD64 D Compiler v2.066.0 with DUB version 0.9.22 and I've got the following dependencies in my dub.json: "dependencies": { "vibe-d": "~>0.7.19", "temple": "~>0.7.3" } It might not solve your pro

pyd and converting arrays of strings

2015-03-18 Thread Laeeth Isharc via Digitalmars-d-learn
Hi I am using PyD with latest stable LDC on Arch Linux 64 bit. I have various structures I am trying to wrap to pass to python. For example: struct PlotLines { KPDateTime[] start_dates; KPDateTime[] end_dates; double[] y; string[] colors; long[] weight

Re: calling C variadic arguments with no 'argc' and only variadic arguments

2015-03-18 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 05:38:40 UTC, Ali Çehreli wrote: On 03/17/2015 06:13 PM, Laeeth Isharc wrote: > DMD gave me an error message for the following declarations: > > double mgl_rnd (...); > double mgl_rnd_ (...); Are you sure those are the right signatures? I don't think those functi

template instantiation question

2015-03-18 Thread Dmitri Makarov via Digitalmars-d-learn
I have three modules a.d, b.d, and c.d: file a.d:``` module i.a; import i.c, i.b; final class A { public: void foo() { a.transmogrify(); } S!void a; } ``` -- file b.d:``` module i.b; import i.a, i.c; class B { public: S!void b; } ``` -- file c.d:``` module

Re: Understanding behavior of member functions loaded at runtime

2015-03-18 Thread Ali Çehreli via Digitalmars-d-learn
On 03/18/2015 09:02 AM, Maeriden wrote: On Wednesday, 18 March 2015 at 07:57:39 UTC, Kagamin wrote: You violate the ABI, try to use delegates instead of functions. I'm sorry,I don't understand what you mean. The types that you cast to are not correct. In D, callable member function pointers

Re: template instantiation question

2015-03-18 Thread Ali Çehreli via Digitalmars-d-learn
On 03/18/2015 11:03 AM, Dmitri Makarov wrote: > When these modules compiled separately, I assume, both a.o and b.o > contain a definition of i.c.S!void.S.transmogrify() instance. That is very likely but I played with different three files for a while and failed to see that. > how is the symbo

Re: template instantiation question

2015-03-18 Thread Dmitri Makarov via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 18:26:07 UTC, Ali Çehreli wrote: $ nm b.o | grep transmogrify W _D1c8__T1CTvZ1C12transmogrifyMFNaNbNiNfZi What compiler do you use? For me, neither a.o nor b.o contain transmogrify definition: $ dmd -c -Ix x/i/a.d $ nm a.o | grep trans

Re: pyd and converting arrays of strings

2015-03-18 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 17:09:27 UTC, Laeeth Isharc wrote: Hi I am using PyD with latest stable LDC on Arch Linux 64 bit. I have various structures I am trying to wrap to pass to python. For example: struct PlotLines { KPDateTime[] start_dates; KPDateTime[] end_dates;

Re: Should this work: export extern(C) auto ...

2015-03-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 15:50:16 UTC, Robert M. Münch wrote: struct1 is visible in the DLL, struct2 is not visible in the DLL. It will not work because a function with an auto return value is actually a template, and unused templates won't be put into a dll.

Re: template instantiation question

2015-03-18 Thread Ali Çehreli via Digitalmars-d-learn
(My earlier response seems to be lost; trying one more time.) On 03/18/2015 12:09 PM, Dmitri Makarov wrote: > On Wednesday, 18 March 2015 at 18:26:07 UTC, Ali Çehreli wrote: >> $ nm b.o | grep transmogrify >> W _D1c8__T1CTvZ1C12transmogrifyMFNaNbNiNfZi > > What compiler do you u

Re: pyd and converting arrays of strings

2015-03-18 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 20:58:56 UTC, John Colvin wrote: On Wednesday, 18 March 2015 at 17:09:27 UTC, Laeeth Isharc wrote: Hi I am using PyD with latest stable LDC on Arch Linux 64 bit. I have various structures I am trying to wrap to pass to python. For example: struct PlotLines {