Re: Proper Use of Assert and Enforce

2012-03-14 Thread Jonathan M Davis
On Wednesday, March 14, 2012 06:44:19 Chris Pons wrote: > I'm new, and trying to incorporate assert and enforce into my > program properly. > > My question revolves around, the fact that assert is only > evaluated when using the debug switch. assert has nothing to do with the debug switch. All th

Re: Simple operator precidence chart (and associativity)?

2012-03-14 Thread Timon Gehr
On 03/14/2012 01:20 AM, Nick Sabalausky wrote: "Timon Gehr" wrote in message >> << >>> // 8 shift operators == !=> < >=<= \ // 9 relational operators !> !< !>= !<=<>\ !<> <>= !<>= in \ !in is !is & // 10 bitwise AND (ambiguous with 9) ^ // 11 bitwi

Re: Proper Use of Assert and Enforce

2012-03-14 Thread Dmitry Olshansky
On 14.03.2012 9:44, Chris Pons wrote: I'm new, and trying to incorporate assert and enforce into my program properly. My question revolves around, the fact that assert is only evaluated when using the debug switch. I read that assert throws a more serious exception than enforce does, is this cor

Re: Simple operator precidence chart (and associativity)?

2012-03-14 Thread Nick Sabalausky
"Timon Gehr" wrote in message news:jjpmov$305u$1...@digitalmars.com... > On 03/14/2012 01:20 AM, Nick Sabalausky wrote: >> "Timon Gehr" wrote in message > >>> >> << >>> // 8 shift operators >>> == !=> < >=<= \ // 9 relational operators >>> !> !< !>= !<=<>\ >>> !<> <>= !<>= in \ >>>

Re: Math Libraries (and vectors, matrices, etc)

2012-03-14 Thread David
Am 13.03.2012 21:34, schrieb Kiith-Sa: SciD is a scientific math library providing vectors/matrices of arbitrary sizes, but not useful at all for game development. See gl3n for a game-oriented vector/matrix library: https://bitbucket.org/dav1d/gl3n Also, AFAIK, Manu is working on what should en

Re: Simple operator precidence chart (and associativity)?

2012-03-14 Thread Jos van Uden
On 14-3-2012 0:14, Timon Gehr wrote: I don't think there is, but I think I can create one: ! // 1 template instantiation => // 2 goesto, binds weaker to the right . ++ -- ( [ // 3 postfix operators ^^ // 4 power (right-associative) & ++ -- * - + ! ~ // 5 prefix operators * / % // 6 multiplicativ

Re: Does synchronized support recursive locking?

2012-03-14 Thread Steven Schveighoffer
On Tue, 13 Mar 2012 16:26:08 -0400, Alex Rønne Petersen wrote: What the title says. It seems that core.sync.mutex does, but not sure about the synchronized statement. Yes. A simple test would have shown you that ;) But it would be good to put this in the docs. -Steve

Re: Stride

2012-03-14 Thread Chris W.
On Tuesday, 14 February 2012 at 21:09:09 UTC, Ali Çehreli wrote: On 02/14/2012 12:59 PM, RenatoL wrote: mmmhhh this is interesting nevertheless i don't understand the solution of my problem, and i cannot even understand it's origin: void main() { string s1 = "abcd"; s1 = s1[stride

Re: Does synchronized support recursive locking?

2012-03-14 Thread Alex Rønne Petersen
On 14-03-2012 13:24, Steven Schveighoffer wrote: On Tue, 13 Mar 2012 16:26:08 -0400, Alex Rønne Petersen wrote: What the title says. It seems that core.sync.mutex does, but not sure about the synchronized statement. Yes. A simple test would have shown you that ;) But it would be good to put

Re: Simple operator precidence chart (and associativity)?

2012-03-14 Thread Timon Gehr
On 03/14/2012 01:23 PM, Jos van Uden wrote: On 14-3-2012 0:14, Timon Gehr wrote: I don't think there is, but I think I can create one: ! // 1 template instantiation => // 2 goesto, binds weaker to the right . ++ -- ( [ // 3 postfix operators ^^ // 4 power (right-associative) & ++ -- * - + ! ~ /

Re: Vector Swizzling in D

2012-03-14 Thread Dmitry Olshansky
On 14.03.2012 18:57, Boscop wrote: Hi everyone, I wrote a blog post for people who know a bit of D and want to dig deeper, it shows different approaches to get vector swizzling syntax in D: http://boscop.tk/blog/?p=1 There is nothing revolutionary involved but it might still be useful to someo

Re: Vector Swizzling in D

2012-03-14 Thread Dmitry Olshansky
On 14.03.2012 19:03, Dmitry Olshansky wrote: On 14.03.2012 18:57, Boscop wrote: Hi everyone, I wrote a blog post for people who know a bit of D and want to dig deeper, it shows different approaches to get vector swizzling syntax in D: http://boscop.tk/blog/?p=1 There is nothing revolutionary

Re: What's the correct opEquals signature for structs?

2012-03-14 Thread Johannes Pfau
Am Tue, 13 Mar 2012 19:31:45 +0100 schrieb Alex Rønne Petersen : > On 13-03-2012 19:28, Johannes Pfau wrote: > > My std.uuid module doesn't compile with the latest dmd. I guess it's > > because of a wrong opEquals signature, this is what I have now: > > > > -- > > @safe pure nothrow bool o

Re: Vector Swizzling in D

2012-03-14 Thread H. S. Teoh
On Wed, Mar 14, 2012 at 03:57:02PM +0100, Boscop wrote: > Hi everyone, > > I wrote a blog post for people who know a bit of D and want to dig > deeper, it shows different approaches to get vector swizzling syntax > in D: > > http://boscop.tk/blog/?p=1 > > There is nothing revolutionary involved

Checking for possibility of implicit conversions

2012-03-14 Thread H. S. Teoh
How do I check if a given type T can be implicitly converted to some type S at compile-time? I'm trying to write a signature constraint for a template function that should only be instantiated if the parameter type can be implicitly assigned to some given type S. struct S(T) {

Re: Checking for possibility of implicit conversions

2012-03-14 Thread Alex Rønne Petersen
On 14-03-2012 18:07, H. S. Teoh wrote: How do I check if a given type T can be implicitly converted to some type S at compile-time? I'm trying to write a signature constraint for a template function that should only be instantiated if the parameter type can be implicitly assigned to some given ty

Re: Checking for possibility of implicit conversions

2012-03-14 Thread H. S. Teoh
On Wed, Mar 14, 2012 at 06:08:24PM +0100, Adam D. Ruppe wrote: > if(is(T : S)) > > http://dlang.org/expression.html#IsExpression > > this is form #2. Ahh, thanks. I keep forgetting what the various forms of is() do... sigh. Another question: is wstring assignable to dstring, or string to wstrin

Re: Vector Swizzling in D

2012-03-14 Thread Don Clugston
On 14/03/12 15:57, Boscop wrote: Hi everyone, I wrote a blog post for people who know a bit of D and want to dig deeper, it shows different approaches to get vector swizzling syntax in D: http://boscop.tk/blog/?p=1 There is nothing revolutionary involved but it might still be useful to someone

Re: Vector Swizzling in D

2012-03-14 Thread Boscop
On Wednesday, 14 March 2012 at 17:35:06 UTC, Don Clugston wrote: In the last bit of code, why not use CTFE for valid(string s) instead of templates? bool valid(string s) { foreach(c; s) { if (c < 'w' || c > 'z') return false; } return true; } In fact you can use CTFE for the o

Re: Checking for possibility of implicit conversions

2012-03-14 Thread Nick Sabalausky
"H. S. Teoh" wrote in message news:mailman.662.1331746435.4860.digitalmars-d-le...@puremagic.com... > On Wed, Mar 14, 2012 at 06:08:24PM +0100, Adam D. Ruppe wrote: >> if(is(T : S)) >> >> http://dlang.org/expression.html#IsExpression >> >> this is form #2. > > Ahh, thanks. I keep forgetting what

Re: Checking for possibility of implicit conversions

2012-03-14 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:jjqp0n$1pga$1...@digitalmars.com... > > What might make that a little confusing, though, is that string *literals* > which are not suffixed with c/w/d are *not* necessarily string, but rather > can acually *be* (ie, not "implicitly convertable to", but th

Re: Simple operator precidence chart (and associativity)?

2012-03-14 Thread Stewart Gordon
On 13/03/2012 23:14, Timon Gehr wrote: (Also, for associativity: Assign and OpAssign are right-associative and everything else is left-associative, correct?) Power is right-associative too. You forgot the conditional operator. And the relational operators are non-associative (a == b == c

Re: Proper Use of Assert and Enforce

2012-03-14 Thread Spacen Jasset
On 14/03/2012 09:59, Dmitry Olshansky wrote: ... To make it real simple: - assert on stuff you know has to be true regardless of circumstances and not dependent on any possible external factors. - enforce on stuff that must be true, but in general can fail like "file not found", etc. and/or depe

Re: Proper Use of Assert and Enforce

2012-03-14 Thread Jonathan M Davis
On Wednesday, March 14, 2012 20:15:16 Spacen Jasset wrote: > Is enforce then a way of generating exceptions in an easier way rather > than using some sort of "if (failure) throw" syntax? In other words, I > assume it's a mechanism to help you use exceptions, and not some new > semantic. It is pure

comma inside is expression

2012-03-14 Thread Jos van Uden
I've been reading the tutorial on templates and found this example: template rank(T) { static if (is(T t == U[], U)) // is T an array of U, for some type U? enum rank = 1 + rank!(U); // then let’s recurse down. else enum rank = 0; // Base case, ending the recursion. } T

Re: Proper Use of Assert and Enforce

2012-03-14 Thread Chris Pons
Thank you for the valuable information! The difference between assert and enforce is now clearer in my mind. Also, that's a great trick with enforce. On Thursday, 15 March 2012 at 01:08:02 UTC, Jonathan M Davis wrote: On Wednesday, March 14, 2012 20:15:16 Spacen Jasset wrote: Is enforce then

Re: comma inside is expression

2012-03-14 Thread Nathan M. Swan
On Thursday, 15 March 2012 at 02:34:45 UTC, Jos van Uden wrote: I've been reading the tutorial on templates and found this example: template rank(T) { static if (is(T t == U[], U)) // is T an array of U, for some type U? enum rank = 1 + rank!(U); // then let’s recurse down. e

DLL's and D

2012-03-14 Thread Chris Pons
I haven't used DLL's much, especially one I've built on my own, so guidance would be appreciated. I'm trying to figure out how to build a DLL which was written in D but i'm not sure i'm doing this right. I'm using VS2010 and Visual D. Visual D has a template for Dll's in D, so I used that to

Re: DLL's and D

2012-03-14 Thread Mike Parker
On 3/15/2012 12:26 PM, Chris Pons wrote: I haven't used DLL's much, especially one I've built on my own, so guidance would be appreciated. I'm trying to figure out how to build a DLL which was written in D but i'm not sure i'm doing this right. I'm using VS2010 and Visual D. Visual D has a temp