Re: __gshared and static constructors

2012-01-04 Thread Jacob Carlborg
On 2012-01-04 20:14, Alex Rønne Petersen wrote: Hi, When using __gshared for variables at module level, it is my understanding that they should be initialized in the shared static this constructor. My question is: When having __gshared variables inside classes, where should I initialize these? D

An issue with lazy delegates

2012-01-04 Thread Andrej Mitrovic
import std.stdio; void test(T)(lazy T dg) { test2(dg); } void test2(T)(lazy T dg) { dg();// nothing happens dg()(); // have to use double-invocation instead } void main() { test({ writeln("test"); }); } Do you think it would be possible for the compiler to avoid wrapping de

Re: __gshared and static constructors

2012-01-04 Thread Mike Parker
On 1/5/2012 4:14 AM, Alex Rønne Petersen wrote: Hi, When using __gshared for variables at module level, it is my understanding that they should be initialized in the shared static this constructor. My question is: When having __gshared variables inside classes, where should I initialize these? D

Re: out default argument of void

2012-01-04 Thread Jesse Phillips
On Wednesday, 4 January 2012 at 23:02:24 UTC, Simen Kjærås wrote: On Wed, 04 Jan 2012 23:40:28 +0100, Jesse Phillips wrote: On Wednesday, 4 January 2012 at 22:19:28 UTC, Caligo wrote: 1. Are there any other solutions ? 2. Would it make sense to have 'out default argument of void' in D? Ou

Re: out default argument of void

2012-01-04 Thread Caligo
On Wed, Jan 4, 2012 at 4:40 PM, Jesse Phillips wrote: > > Out parameters are initialized. The declaration you want is: > > bool fun(double theta, A a = A.init, B b = B.init, C c = C.init){ /* ... */ > } > In my case A, B, and C are structs, so that works the way I wanted it. Nice! It doesn't, ho

Re: out default argument of void

2012-01-04 Thread Ali Çehreli
On 01/04/2012 02:19 PM, Caligo wrote: > I have a function that looks something like this: > > bool fun(double theta, out A a, out B b, out C c){ /* ... */ } > > if fun() returns false, then nothing is supposed to be assigned to a, > b, c. If it returns true, then values are assigned to a, b, c.

Re: out default argument of void

2012-01-04 Thread Simen Kjærås
On Wed, 04 Jan 2012 23:19:18 +0100, Caligo wrote: I have a function that looks something like this: bool fun(double theta, out A a, out B b, out C c){ /* ... */ } if fun() returns false, then nothing is supposed to be assigned to a, b, c. If it returns true, then values are assigned to a, b

Re: out default argument of void

2012-01-04 Thread Simen Kjærås
On Wed, 04 Jan 2012 23:40:28 +0100, Jesse Phillips wrote: On Wednesday, 4 January 2012 at 22:19:28 UTC, Caligo wrote: 1. Are there any other solutions ? 2. Would it make sense to have 'out default argument of void' in D? Out parameters are initialized. The declaration you want is: bool fu

Re: out default argument of void

2012-01-04 Thread Timon Gehr
On 01/04/2012 11:19 PM, Caligo wrote: I have a function that looks something like this: bool fun(double theta, out A a, out B b, out C c){ /* ... */ } if fun() returns false, then nothing is supposed to be assigned to a, b, c. If it returns true, then values are assigned to a, b, c. Also, th

question -property

2012-01-04 Thread sclytrack
.property = "test"; .method = "test"; .method("test"); What does -property exactly do? If you had like a dynamic where you don't know if it's member is a property or a method. You would choose method right? scratch the invalid ones below. --- .property="test"; .pr

Re: Enumerating structs?

2012-01-04 Thread Heywood Floyd
> Yeah, D feels like that to me too, sometimes. Anyways, for your question - > would using the struct name be good enough? They're easy to get hold of > and usable in switch statements. > > If not, how about this: > > > import std.typetuple; > > struct TypeEnum( T... ) { > static pure nothrow @

Re: out default argument of void

2012-01-04 Thread Jesse Phillips
On Wednesday, 4 January 2012 at 22:19:28 UTC, Caligo wrote: 1. Are there any other solutions ? 2. Would it make sense to have 'out default argument of void' in D? Out parameters are initialized. The declaration you want is: bool fun(double theta, A a = A.init, B b = B.init, C c = C.init){ /*

__gshared and static constructors

2012-01-04 Thread Alex Rønne Petersen
Hi, When using __gshared for variables at module level, it is my understanding that they should be initialized in the shared static this constructor. My question is: When having __gshared variables inside classes, where should I initialize these? Do classes have a shared static this construct

out default argument of void

2012-01-04 Thread Caligo
I have a function that looks something like this: bool fun(double theta, out A a, out B b, out C c){  /* ... */ } if fun() returns false, then nothing is supposed to be assigned to a, b, c. If it returns true, then values are assigned to a, b, c. Also, there are two ways to call fun(): If I'm