Re: Multiple assignment

2011-02-26 Thread spir
On 02/26/2011 01:56 AM, bearophile wrote: Is this program showing a bug in multiple assignments (DMD 2.052)? void main() { int i; int[2] x; i, x[i] = 1; assert(x == [1, 0]); // OK int j; int[2] y; y[j], j = 1; assert(y == [0, 0]); // Not OK } At the

Re: Multiple assignment

2011-02-26 Thread spir
On 02/26/2011 04:26 AM, Steven Schveighoffer wrote: Let me fix that for you: func(j++, y[j]) That should be illegal: a statement used as expression, but keeping it's effect anyway, and not the least kind of, namely an assignment, meaning a change of the program state. Denis --

Re: Multiple assignment

2011-02-26 Thread Jonathan M Davis
On Saturday 26 February 2011 00:51:45 spir wrote: On 02/26/2011 04:26 AM, Steven Schveighoffer wrote: Let me fix that for you: func(j++, y[j]) That should be illegal: a statement used as expression, but keeping it's effect anyway, and not the least kind of, namely an assignment,

Icons

2011-02-26 Thread Joel Christensen
I noticed in windows with D you can use .res (eg. dmd main.d smile.res) files for icons any way. but how do you make icon .res files?

Re: Interfacing with c and platform dependent sizes

2011-02-26 Thread Jacob Carlborg
On 2011-02-26 01:28, simendsjo wrote: C is not my strong side, so I'm having some problems wrapping some code. I found a couple of sources on this: 1) http://www.digitalmars.com/d/2.0/htomodule.html 2) http://www.digitalmars.com/d/2.0/interfaceToC.html 1) C's long is the same as D's int. long

Re: Interfacing with c and platform dependent sizes

2011-02-26 Thread Jacob Carlborg
On 2011-02-26 02:35, Jonathan M Davis wrote: On Friday, February 25, 2011 17:16:31 simendsjo wrote: On 26.02.2011 02:06, bearophile wrote: simendsjo: So.. A long in C is the same as the platform size? And long long doesn't exist in 64 bit? In D the size of int/uint is 32 bits and long/ulong

Re: std.xml empty element

2011-02-26 Thread Jacob Carlborg
On 2011-02-26 07:20, Tom wrote: El 25/02/2011 20:07, Jacob Carlborg escribió: On 2011-02-25 21:11, Tom wrote: El 24/02/2011 19:40, Tom escribió: El 24/02/2011 09:51, Jacob Carlborg escribió: On 2011-02-24 06:48, Tom wrote: Hi, how can I create an empty element with current D2 std.xml

Problem with std.regex: *+? not allowed in atom

2011-02-26 Thread Jacob Carlborg
I'm trying to use the std.regex module but when I run my application I get an exception. The exception message says: *+? not allowed in atom The code I have is: import std.regex; void main () { regex(`\.(?=(?:[^\]*\[^\]*\)*(?![^\]*\))`, m); } I'm compiling this with DMD 2.052 on Mac OS

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread Magnus Lie Hetland
On 2011-02-26 01:20:49 +0100, Jonathan M Davis said: So, using such assertions makes good sense when you control both the caller and the callee and it's something that should never happen. Yeah, in my case that's what's going on. I'll only be using the contracts during testing anyway, and

Re: Problem with std.regex: *+? not allowed in atom

2011-02-26 Thread Dmitry Olshansky
On 26.02.2011 14:10, Jacob Carlborg wrote: I'm trying to use the std.regex module but when I run my application I get an exception. The exception message says: *+? not allowed in atom The code I have is: import std.regex; void main () { regex(`\.(?=(?:[^\]*\[^\]*\)*(?![^\]*\))`, m); }

Re: Icons

2011-02-26 Thread J Chapman
== Quote from Joel Christensen (joel...@gmail.com)'s article I noticed in windows with D you can use .res (eg. dmd main.d smile.res) files for icons any way. but how do you make icon .res files? With a resource compiler. Digital Mars supplies one as part of its C++ utilities package:

Re: Problem with std.regex: *+? not allowed in atom

2011-02-26 Thread Jacob Carlborg
On 2011-02-26 12:29, Dmitry Olshansky wrote: On 26.02.2011 14:10, Jacob Carlborg wrote: I'm trying to use the std.regex module but when I run my application I get an exception. The exception message says: *+? not allowed in atom The code I have is: import std.regex; void main () {

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread Jonathan M Davis
On Saturday 26 February 2011 03:24:15 Magnus Lie Hetland wrote: On 2011-02-26 01:20:49 +0100, Jonathan M Davis said: So, using such assertions makes good sense when you control both the caller and the callee and it's something that should never happen. Yeah, in my case that's what's

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread spir
On 02/26/2011 12:24 PM, Magnus Lie Hetland wrote: However, I could always add a call to my unit test, run it, and see it crash -- and then comment it out. Doesn't seem like the prettiest way to handle things, but it's OK, I guess together with the idea of making the contracts super-simple (and

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread David Nadlinger
On 2/26/11 1:15 PM, Jonathan M Davis wrote: […] And from a perfectly practical standpoint, as soon as your code ends up in a library, assertions are generally useless anyway,[…] I don't quite think asserts are useless in libraries. If you need to care about performance in a library, you hit

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread Magnus Lie Hetland
On 2011-02-26 13:15:58 +0100, Jonathan M Davis said: On Saturday 26 February 2011 03:24:15 Magnus Lie Hetland wrote: OK. I had the impression that using assert() in contracts was standard, also for API functions. I thought contracts fulfilled a similar sort of function to assert(), in that

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread Magnus Lie Hetland
On 2011-02-26 15:20:19 +0100, David Nadlinger said: On 2/26/11 1:15 PM, Jonathan M Davis wrote: [...] And from a perfectly practical standpoint, as soon as your code ends up in a library, assertions are generally useless anyway,[...] I don't quite think asserts are useless in libraries. If

Is std.cover deprecated or gone?

2011-02-26 Thread Magnus Lie Hetland
It's documented here... http://www.digitalmars.com/d/2.0/phobos/std_cover.html ... but I can't find it in the Phobos source. (Also, I can't import it -- which is perhaps the most pressing issue :) It's just that I'm using rdmd (for convenience), but then I don't know where any coverage

Re: Interfacing with c and platform dependent sizes

2011-02-26 Thread Mike Wey
On 02/26/2011 11:49 AM, Jacob Carlborg wrote: On 2011-02-26 01:28, simendsjo wrote: C is not my strong side, so I'm having some problems wrapping some code. I found a couple of sources on this: 1) http://www.digitalmars.com/d/2.0/htomodule.html 2)

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread David Nadlinger
On 2/26/11 4:08 PM, Magnus Lie Hetland wrote: On 2011-02-26 15:20:19 +0100, David Nadlinger said: On 2/26/11 1:15 PM, Jonathan M Davis wrote: [...] And from a perfectly practical standpoint, as soon as your code ends up in a library, assertions are generally useless anyway,[...] I don't

Re: Problem with std.regex: *+? not allowed in atom

2011-02-26 Thread Jacob Carlborg
On 2011-02-26 12:29, Dmitry Olshansky wrote: On 26.02.2011 14:10, Jacob Carlborg wrote: I'm trying to use the std.regex module but when I run my application I get an exception. The exception message says: *+? not allowed in atom The code I have is: import std.regex; void main () {

Re: Interfacing with c and platform dependent sizes

2011-02-26 Thread simendsjo
On 26.02.2011 17:06, Mike Wey wrote: On 02/26/2011 11:49 AM, Jacob Carlborg wrote: On 2011-02-26 01:28, simendsjo wrote: C is not my strong side, so I'm having some problems wrapping some code. I found a couple of sources on this: 1) http://www.digitalmars.com/d/2.0/htomodule.html 2)

Re: Are function pointers compile time constants?

2011-02-26 Thread Dan Olson
d coder dlang.co...@gmail.com writes: Greetings I tried to initialize a struct member with a function pointer, and found that DMD2 did not like it. Are not function pointers compile time constants? And why they should not be? Regards - Cherry I just want to point out that this *should*

Re: Is std.cover deprecated or gone?

2011-02-26 Thread Magnus Lie Hetland
On 2011-02-26 16:30:10 +0100, Magnus Lie Hetland said: It's documented here... http://www.digitalmars.com/d/2.0/phobos/std_cover.html ... but I can't find it in the Phobos source. (Also, I can't import it -- which is perhaps the most pressing issue :) It's just that I'm using rdmd (for

Re: Problem with std.regex: *+? not allowed in atom

2011-02-26 Thread Dmitry Olshansky
On 26.02.2011 19:52, Jacob Carlborg wrote: On 2011-02-26 12:29, Dmitry Olshansky wrote: On 26.02.2011 14:10, Jacob Carlborg wrote: I'm trying to use the std.regex module but when I run my application I get an exception. The exception message says: *+? not allowed in atom The code I have is:

Re: Multiple assignment

2011-02-26 Thread Dan Olson
Jonathan M Davis jmdavisp...@gmx.com writes: On Friday, February 25, 2011 17:31:36 Ali Çehreli wrote: On 02/25/2011 05:09 PM, bearophile wrote: int j; int[2] y; y[j] = j = 1; I think that's undefined behavior in C and C++. It is not defined whether j's previous or

Re: Interfacing with c and platform dependent sizes

2011-02-26 Thread Mike Wey
On 02/26/2011 05:58 PM, simendsjo wrote: On 26.02.2011 17:06, Mike Wey wrote: On 02/26/2011 11:49 AM, Jacob Carlborg wrote: On 2011-02-26 01:28, simendsjo wrote: C is not my strong side, so I'm having some problems wrapping some code. I found a couple of sources on this: 1)

Re: Icons

2011-02-26 Thread Joel Christensen
On 27-Feb-11 12:56 AM, J Chapman wrote: == Quote from Joel Christensen (joel...@gmail.com)'s article I noticed in windows with D you can use .res (eg. dmd main.d smile.res) files for icons any way. but how do you make icon .res files? With a resource compiler. Digital Mars supplies one as

Initializing a class pointer

2011-02-26 Thread Tyro[a.c.edwards]
class Class{} void main() { Class myClass; Class* pClass0 = myClass; // OK Class* pClass1 = new Class; // Error: cannot implicitly convert [8] // expression (new Class) of type t.Class // to test.Class* Class* pClass2 = (new

Re: Icons

2011-02-26 Thread Joel Christensen
On 27-Feb-11 11:24 AM, Joel Christensen wrote: On 27-Feb-11 12:56 AM, J Chapman wrote: == Quote from Joel Christensen (joel...@gmail.com)'s article I noticed in windows with D you can use .res (eg. dmd main.d smile.res) files for icons any way. but how do you make icon .res files? With a

Re: Initializing a class pointer

2011-02-26 Thread Simen kjaeraas
Tyro[a.c.edwards] nos...@home.com wrote: class Class{} void main() { Class myClass; Class* pClass0 = myClass; // OK Class* pClass1 = new Class; // Error: cannot implicitly convert [8] // expression (new Class) of type t.Class //

Re: Initializing a class pointer

2011-02-26 Thread Tyro[a.c.edwards]
On 2/27/2011 8:10 AM, Simen kjaeraas wrote: Tyro[a.c.edwards] nos...@home.com wrote: class Class{} void main() { Class myClass; Class* pClass0 = myClass; // OK Class* pClass1 = new Class; // Error: cannot implicitly convert [8] // expression (new Class) of type t.Class // to test.Class*

Re: Initializing a class pointer

2011-02-26 Thread Simen kjaeraas
Tyro[a.c.edwards] nos...@home.com wrote: I'm trying to convert some c++ code that defines T func(par...) { Controller * pCtrl = WinGetLongController * (hwnd); . . . switch(msg) { case FirstMatch: pCtrl = new Controller (hwnd, reinterpret_castCREATESTRUCT *

Re: Initializing a class pointer

2011-02-26 Thread Tyro[a.c.edwards]
On 2/27/2011 8:52 AM, Simen kjaeraas wrote: Tyro[a.c.edwards] nos...@home.com wrote: I'm trying to convert some c++ code that defines T func(par...) { Controller * pCtrl = WinGetLongController * (hwnd); . . . switch(msg) { case FirstMatch: pCtrl = new Controller (hwnd,

Re: Multiple assignment

2011-02-26 Thread Jonathan M Davis
On Saturday 26 February 2011 11:18:20 Dan Olson wrote: Jonathan M Davis jmdavisp...@gmx.com writes: On Friday, February 25, 2011 17:31:36 Ali Çehreli wrote: On 02/25/2011 05:09 PM, bearophile wrote: int j; int[2] y; y[j] = j = 1; I think that's undefined

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread Jonathan M Davis
On Saturday 26 February 2011 07:03:29 Magnus Lie Hetland wrote: On 2011-02-26 13:15:58 +0100, Jonathan M Davis said: On Saturday 26 February 2011 03:24:15 Magnus Lie Hetland wrote: OK. I had the impression that using assert() in contracts was standard, also for API functions. I thought

Re: Initializing a class pointer

2011-02-26 Thread Tyro[a.c.edwards]
On 2/27/2011 9:46 AM, Tyro[a.c.edwards] wrote: On 2/27/2011 8:52 AM, Simen kjaeraas wrote: Tyro[a.c.edwards] nos...@home.com wrote: I'm trying to convert some c++ code that defines T func(par...) { Controller * pCtrl = WinGetLongController * (hwnd); . . . switch(msg) { case FirstMatch: pCtrl

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread Jonathan M Davis
On Saturday 26 February 2011 08:23:41 David Nadlinger wrote: On 2/26/11 4:08 PM, Magnus Lie Hetland wrote: On 2011-02-26 15:20:19 +0100, David Nadlinger said: On 2/26/11 1:15 PM, Jonathan M Davis wrote: [...] And from a perfectly practical standpoint, as soon as your code ends up in a

Re: Additional path for libs

2011-02-26 Thread Bekenn
Apologies for the late reply, but this could help: As you've already seen in the other replies, the provided sc.ini file is confounding your attempts at setting the LIB environment variable. However, OPTLINK's search path for sc.ini includes the current directory, so if you're reluctant to

Re: Interfacing with c and platform dependent sizes

2011-02-26 Thread Bekenn
On 2/25/2011 7:24 PM, Steven Schveighoffer wrote: BTW, I think long long is a gnu extension, it's not standard C (I don't think long long exists in Visual C for instance). I'm pretty sure it's standard as of C99 (though not yet for C++; that's coming with C++0x). MSVC does indeed support it.

Re: Initializing a class pointer

2011-02-26 Thread Bekenn
On 2/26/2011 5:33 PM, Tyro[a.c.edwards] wrote: Ok, that's essentially what I have, except that I used Controller pCtrl vice auto. WinGetLong however, is a template that calls GetWindowLongPtrA() and casts it's result (in this case) to Controller. GetWindowLongPtrA() returns LONG_PTR (aka int)