lvalue method

2010-10-08 Thread Benjamin Thaut
Hi, I'm writing a vec4 math struct and I have a method of which the return value has to be a lvalue so I wonder which is the correct way to do this: vec4 Normalize() const { ... } //won't work, not a lvalue ref vec4 Normalize() const { vec4 temp; ... return temp; } //will this lead to a

Re: Static problem

2010-10-08 Thread Bob Cowdery
On 07/10/2010 21:32, Stanislav Blinov wrote: Steven Schveighoffer wrote: What I'd propose is either: 1) Create your own lock-free associative array (yup, reinvent the wheel to introduce AA to the world of 'shared') 2) In this small case it may seem best (though mind that often such cases

Re: Static problem

2010-10-08 Thread Stanislav Blinov
Bob Cowdery wrote: On 07/10/2010 21:32, Stanislav Blinov wrote: Steven Schveighoffer wrote: What I'd propose is either: 1) Create your own lock-free associative array (yup, reinvent the wheel to introduce AA to the world of 'shared') 2) In this small case it may seem best (though mind that

Re: lvalue method

2010-10-08 Thread Stanislav Blinov
Benjamin Thaut wrote: Hi, I'm writing a vec4 math struct and I have a method of which the return value has to be a lvalue so I wonder which is the correct way to do this: vec4 Normalize() const { ... } //won't work, not a lvalue ref vec4 Normalize() const { vec4 temp; ... return temp;

Re: lvalue method

2010-10-08 Thread Simen kjaeraas
Benjamin Thaut c...@benjamin-thaut.de wrote: Hi, I'm writing a vec4 math struct and I have a method of which the return value has to be a lvalue so I wonder which is the correct way to do this: vec4 Normalize() const { ... } //won't work, not a lvalue ref vec4 Normalize() const { vec4

Re: lvalue method

2010-10-08 Thread Lars T. Kyllingstad
On Fri, 08 Oct 2010 09:33:22 +0200, Benjamin Thaut wrote: Hi, I'm writing a vec4 math struct and I have a method of which the return value has to be a lvalue so I wonder which is the correct way to do this: vec4 Normalize() const { ... } //won't work, not a lvalue ref vec4 Normalize()

question about property for built-in type

2010-10-08 Thread %u
Hi, I'm learning D right now and got a question about property. I tried to add a property for built-in type like the following @property bool equalZero(double a) { return a == 0.0; } void main() { ... double x = 4.4; bool isXZero = x.equalZero; ... } but got an error message main.d(75):

Re: question about property for built-in type

2010-10-08 Thread Denis Koroskin
On Fri, 08 Oct 2010 16:19:43 +0400, %u djvsr...@gmail.com wrote: Hi, I'm learning D right now and got a question about property. I tried to add a property for built-in type like the following @property bool equalZero(double a) { return a == 0.0; } void main() { ... double x = 4.4; bool

Re: question about property for built-in type

2010-10-08 Thread Stanislav Blinov
08.10.2010 16:19, %u wrote: Hi, I'm learning D right now and got a question about property. I tried to add a property for built-in type like the following @property bool equalZero(double a) { return a == 0.0; } void main() { ... double x = 4.4; bool isXZero = x.equalZero; ... }

Re: lvalue method

2010-10-08 Thread Steven Schveighoffer
On Fri, 08 Oct 2010 09:26:19 -0400, Benjamin Thaut c...@benjamin-thaut.de wrote: Am 08.10.2010 11:13, schrieb Lars T. Kyllingstad: On Fri, 08 Oct 2010 09:33:22 +0200, Benjamin Thaut wrote: Hi, I'm writing a vec4 math struct and I have a method of which the return value has to be a lvalue

Re: lvalue method

2010-10-08 Thread Simen kjaeraas
Steven Schveighoffer schvei...@yahoo.com wrote: The correct way is to use auto ref as the parameter: struct vec4 { ... vec4 Normalize(auto ref const(vec4) param) {...} } But AFAIK, this doesn't really work. It doesn't, no. I'm not even sure it's scheduled for inclusion. Also, with

Re: lvalue method

2010-10-08 Thread Steven Schveighoffer
On Fri, 08 Oct 2010 09:51:59 -0400, Simen kjaeraas simen.kja...@gmail.com wrote: Steven Schveighoffer schvei...@yahoo.com wrote: The correct way is to use auto ref as the parameter: struct vec4 { ... vec4 Normalize(auto ref const(vec4) param) {...} } But AFAIK, this doesn't really

[D1][expressions] Order Of Evaluation

2010-10-08 Thread %u
/The following binary expressions are evaluated in an implementation-defined order: AssignExpression/../AddExpression/ /It is an error to depend on order of evaluation when it is not specified./ That makes this an error!? y = x + 1; Am I being paranoid or should I be adding more brackets?

Re: Destruction Sequence: module and classes defined within

2010-10-08 Thread Lutger
Lars T. Kyllingstad wrote: On Tue, 05 Oct 2010 23:25:36 +0200, vano wrote: The code below: module used; import std.stdio; class ClassA { this() { writeln(A ctor); } ~this() { writeln(A dtor); } } static this() { writeln(used.sctor); }

Re: [D1][expressions] Order Of Evaluation

2010-10-08 Thread bearophile
%u: That makes this an error!? y = x + 1; Am I being paranoid or should I be adding more brackets? I presume this doesn't need other brackets. And Walter has two or three times stated that he wants to eventually define the order of evaluation in D (as C#/Java), I hope this will happen.

Re: [D1][expressions] Order Of Evaluation

2010-10-08 Thread Denis Koroskin
On Fri, 08 Oct 2010 18:49:36 +0400, %u e...@ee.com wrote: /The following binary expressions are evaluated in an implementation-defined order: AssignExpression/../AddExpression/ /It is an error to depend on order of evaluation when it is not specified./ That makes this an error!? y = x +

Re: [D1][expressions] Order Of Evaluation

2010-10-08 Thread %u
== Quote from Denis Koroskin (2kor...@gmail.com)'s article On Fri, 08 Oct 2010 18:49:36 +0400, %u e...@ee.com wrote: /The following binary expressions are evaluated in an implementation-defined order: AssignExpression/../AddExpression/ /It is an error to depend on order of evaluation

std.regex character consumption

2010-10-08 Thread petevik38
I've been running into a few problems with regular expressions in D. One of the issues I've had recently is matching strings with non ascii characters. As an example: auto re = regex( `(.*)\.txt`, i ); re.printProgram(); auto m = match( bà.txt, re ); writefln( '%s', m.captures[1]

ditto in DDoc

2010-10-08 Thread Tomek Sowiński
More of an English question... dunno - don't know ditto - ? -- Tomek

Re: std.regex character consumption

2010-10-08 Thread Jonathan M Davis
On Friday, October 08, 2010 14:13:36 petevi...@yahoo.com.au wrote: I've been running into a few problems with regular expressions in D. One of the issues I've had recently is matching strings with non ascii characters. As an example: auto re = regex( `(.*)\.txt`, i );

Re: ditto in DDoc

2010-10-08 Thread Yao G.
On Fri, 08 Oct 2010 16:22:33 -0500, Tomek Sowiński j...@ask.me wrote: More of an English question... dunno - don't know ditto - ? http://en.wiktionary.org/wiki/ditto ditto (plural dittos) 1. That which was stated before, the aforesaid, the above, the same. 2. (informal) A duplicate or copy

Re: ditto in DDoc

2010-10-08 Thread Jonathan M Davis
On Friday, October 08, 2010 14:22:33 Tomek Sowiński wrote: More of an English question... dunno - don't know ditto - ? It's a word in and of itself, not the shortening or butchering of another word. According to merriam-webster.com ( http://www.merriam- webster.com/dictionary/ditto ), it

Re: ditto in DDoc

2010-10-08 Thread bearophile
Jonathan M Davis: It's the past participle of the Italian word dire (to say) It was, a long time ago. Today it's detto. Bye, bearophile

Re: ditto in DDoc

2010-10-08 Thread Denis Koroskin
On Sat, 09 Oct 2010 01:22:33 +0400, Tomek Sowiński j...@ask.me wrote: More of an English question... dunno - don't know ditto - ? Ditto is used to indicate that something already said is applicable a second time. In documentation, ditto means that previous comment also applies here. Here

Re: ditto in DDoc

2010-10-08 Thread Jonathan M Davis
On Friday, October 08, 2010 15:17:13 bearophile wrote: Jonathan M Davis: It's the past participle of the Italian word dire (to say) It was, a long time ago. Today it's detto. Bye, bearophile Good to know. I was just going by what Merriam Webster had to say on that one. I know French

A question about DbC

2010-10-08 Thread bearophile
This is a simple D2 class that uses Contracts: import std.c.stdio: printf; class Car { int speed = 0; invariant() { printf(Car invariant: %d\n, speed); assert(speed = 0); } this() { printf(Car constructor: %d\n, speed); speed = 0; }

Re: A question about DbC

2010-10-08 Thread Jonathan M Davis
On Friday 08 October 2010 20:16:10 bearophile wrote: This is a simple D2 class that uses Contracts: import std.c.stdio: printf; class Car { int speed = 0; invariant() { printf(Car invariant: %d\n, speed); assert(speed = 0); } this() {