Re: struct constructors and function parameters

2010-11-10 Thread Adam Burton
Simen kjaeraas wrote: > Adam Burton wrote: > >> I looked into alias this and it does indeed work, unless the alias is to >> a >> function. That has been reported as a bug though >> http://d.puremagic.com/issues/show_bug.cgi?id=2814 > > Wouldn't that be the opposite of what you were discussing e

Re: struct constructors and function parameters

2010-11-09 Thread Simen kjaeraas
Adam Burton wrote: I looked into alias this and it does indeed work, unless the alias is to a function. That has been reported as a bug though http://d.puremagic.com/issues/show_bug.cgi?id=2814 Wouldn't that be the opposite of what you were discussing earlier? alias this lets a struct behav

Re: struct constructors and function parameters

2010-11-09 Thread Adam Burton
Jonathan M Davis wrote: > On Tuesday, November 09, 2010 15:48:27 Adam Burton wrote: >> Hi, >> should the below work? >> >> struct A >> { >> public this(B b) {} >> } >> >> struct B {} >> >> void foo(A a) {} >> >> void main() >> { >> B b; >> foo(b); // Fails >> } >> >> The const

Re: struct constructors and function parameters

2010-11-09 Thread Simen kjaeraas
Adam Burton wrote: True, I had thought of that, but I figured in that situation it would favour int over foo (in same way long vs int) so to access foo you'd need to explicitly use the constructor. On the other hand I suppose its more of a difficult decision when you hit something like below

Re: struct constructors and function parameters

2010-11-09 Thread Jonathan M Davis
On Tuesday, November 09, 2010 15:48:27 Adam Burton wrote: > Hi, > should the below work? > > struct A > { > public this(B b) {} > } > > struct B {} > > void foo(A a) {} > > void main() > { > B b; > foo(b); // Fails > } > > The constructor parameter doesn't need to be a struct,

Re: struct constructors and function parameters

2010-11-09 Thread div0
On 09/11/2010 23:57, Simen kjaeraas wrote: Adam Burton wrote: Hi, should the below work? struct A { public this(B b) {} } struct B {} void foo(A a) {} void main() { B b; foo(b); // Fails } The constructor parameter doesn't need to be a struct, it could be an int. The workaround is to expl

Re: struct constructors and function parameters

2010-11-09 Thread Adam Burton
Simen kjaeraas wrote: > Adam Burton wrote: > >> Hi, >> should the below work? >> >> struct A >> { >> public this(B b) {} >> } >> >> struct B {} >> >> void foo(A a) {} >> >> void main() >> { >> B b; >> foo(b); // Fails >> } >> >> The constructor parameter doesn't need to be a stru

Re: struct constructors and function parameters

2010-11-09 Thread Simen kjaeraas
Adam Burton wrote: Hi, should the below work? struct A { public this(B b) {} } struct B {} void foo(A a) {} void main() { B b; foo(b); // Fails } The constructor parameter doesn't need to be a struct, it could be an int. The workaround is to explicity call the constructo

struct constructors and function parameters

2010-11-09 Thread Adam Burton
Hi, should the below work? struct A { public this(B b) {} } struct B {} void foo(A a) {} void main() { B b; foo(b); // Fails } The constructor parameter doesn't need to be a struct, it could be an int. The workaround is to explicity call the constructor.