Re: Compiling shared example.

2012-10-29 Thread Ali Çehreli
On 10/28/2012 02:46 AM, Peter Sommerfeld wrote: But I wonder why I have do declare the variables shared if the data are declared to be shared. Is that a shortcoming of the current compiler ? I had to look this one up. According to the spec, a shared struct does not mean that the variables of

Re: Copying with immutable arrays

2012-10-29 Thread Ali Çehreli
On 10/28/2012 02:37 AM, Tobias Pankrath wrote: the struct SwA from above does neither correspond to SA nor to SB, it's imo more like SC: struct SC { immutable(int)* i; } Just to confirm, the above indeed works: struct SC { immutable(int)* i; } void main() { immutable(SC)[] arr1;

Re: Copying with immutable arrays

2012-10-29 Thread Tobias Pankrath
On Monday, 29 October 2012 at 06:19:36 UTC, Ali Çehreli wrote: Just to confirm, the above indeed works: struct SC { immutable(int)* i; } void main() { immutable(SC)[] arr1; SC[] arr2 = arr1.dup;// compiles } Oh, I thought I've tried it. [snip] [Really detailed description

Re: scope(failure): get exception

2012-10-29 Thread Jacob Carlborg
On 2012-10-28 13:20, Jonathan M Davis wrote: So, you save one set of braces? I don't see how that really buys you much. Yes, and the try keyword. It would basically be the same as allowing to get the exception in scope(failure) but the catch-statement already supports this. -- /Jacob

__traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Zhenya
Hi! Tell me please,in this code first and second static if,are these equivalent? with arg = 1, __traits(compiles,check(arg);) = true, is(typeof(check(arg))) = false. template ArgType(alias arg) { void check(T)(ref T t) {}; // static if(__traits(compiles,check(arg);))

Re: __traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Zhenya
On Monday, 29 October 2012 at 10:58:51 UTC, Philippe Sigaud wrote: Tell me please,in this code first and second static if,are these equivalent? with arg = 1, __traits(compiles,check(arg);) = true, is(typeof(check(arg))) = false. __traits(compiles, ...) takes an expression, not a string. From

Re: Correct way to map C #define to version

2012-10-29 Thread Sumit Raja
On Monday, 22 October 2012 at 12:44:35 UTC, Regan Heath wrote: On Mon, 22 Oct 2012 12:39:48 +0100, bearophile bearophileh...@lycos.com wrote: Sumit Raja: Am I using version correctly? How is this done usually? I think version is usually meant to be given as compiler switch. Maybe a

Re: scope(failure): get exception

2012-10-29 Thread Jonathan M Davis
On Monday, October 29, 2012 10:30:35 Jacob Carlborg wrote: On 2012-10-28 13:20, Jonathan M Davis wrote: So, you save one set of braces? I don't see how that really buys you much. Yes, and the try keyword. It would basically be the same as allowing to get the exception in scope(failure) but

Re: crash suggestions

2012-10-29 Thread Dan
On Monday, 29 October 2012 at 05:47:21 UTC, Ali Çehreli wrote: First, in order to build the code with dmd 2.060, I had to make opEquals() and getRate() non-const. Thanks for the answers. I am using v2.060 as well so I assume this is not necessary, maybe just a change you made along the way

Re: scope(failure): get exception

2012-10-29 Thread Jacob Carlborg
On 2012-10-29 11:58, Jonathan M Davis wrote: Except that the place that scope statements go in the code is completely different from where catch statements go. catch statements go at the end whereas scope statements go in the middle or even the beginning so that what you're doing in there can

Re: Correct way to map C #define to version

2012-10-29 Thread Regan Heath
On Mon, 29 Oct 2012 11:31:33 -, Sumit Raja sumitr...@gmail.com wrote: Thanks both this works great for structs. Anything similar I can do for enums? Example? (The C/C++ code you're trying to convert..) R -- Using Opera's revolutionary email client: http://www.opera.com/mail/

Re: __traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Jonathan M Davis
On Monday, October 29, 2012 11:42:59 Zhenya wrote: Hi! Tell me please,in this code first and second static if,are these equivalent? with arg = 1, __traits(compiles,check(arg);) = true, is(typeof(check(arg))) = false. In principle, is(typeof(code)) checks whether the code in there is

Re: Correct way to map C #define to version

2012-10-29 Thread Sumit Raja
On Monday, 29 October 2012 at 12:31:56 UTC, Regan Heath wrote: On Mon, 29 Oct 2012 11:31:33 -, Sumit Raja sumitr...@gmail.com wrote: Thanks both this works great for structs. Anything similar I can do for enums? Example? (The C/C++ code you're trying to convert..) Yeah that might

Exception class descendants

2012-10-29 Thread ref2401
Could you please tell me if Phobos contains any Exception class descendants? If so, does the documentation contain a full list of these or even the hierarchy scheme?

Re: Correct way to map C #define to version

2012-10-29 Thread Regan Heath
On Mon, 29 Oct 2012 13:47:46 -, Sumit Raja sumitr...@gmail.com wrote: On Monday, 29 October 2012 at 12:31:56 UTC, Regan Heath wrote: On Mon, 29 Oct 2012 11:31:33 -, Sumit Raja sumitr...@gmail.com wrote: Thanks both this works great for structs. Anything similar I can do for enums?

UTF-8 strings and endianness

2012-10-29 Thread denizzzka
Hi! How to convert D's string to big endian? How to convert to D's string from big endian?

Re: UTF-8 strings and endianness

2012-10-29 Thread Adam D. Ruppe
UTF-8 isn't affected by endianness.

Re: UTF-8 strings and endianness

2012-10-29 Thread Jordi Sayol
Al 29/10/12 16:17, En/na denizzzka ha escrit: Hi! How to convert D's string to big endian? How to convert to D's string from big endian? UTF-8 is always big emdian. -- Jordi Sayol

Re: UTF-8 strings and endianness

2012-10-29 Thread denizzzka
On Monday, 29 October 2012 at 15:22:39 UTC, Adam D. Ruppe wrote: UTF-8 isn't affected by endianness. Ok, thanks!

Re: Exception class descendants

2012-10-29 Thread Jonathan M Davis
On Monday, October 29, 2012 14:55:41 ref2401 wrote: Could you please tell me if Phobos contains any Exception class descendants? If so, does the documentation contain a full list of these or even the hierarchy scheme? Some modules declare exception types that they use (e.g.

Re: UTF-8 strings and endianness

2012-10-29 Thread denizzzka
On Monday, 29 October 2012 at 15:46:43 UTC, Jordi Sayol wrote: Al 29/10/12 16:17, En/na denizzzka ha escrit: Hi! How to convert D's string to big endian? How to convert to D's string from big endian? UTF-8 is always big emdian. Yes. (I thought that the problem in this place but the

Re: UTF-8 strings and endianness

2012-10-29 Thread denizzzka
On Monday, 29 October 2012 at 15:46:43 UTC, Jordi Sayol wrote: Al 29/10/12 16:17, En/na denizzzka ha escrit: Hi! How to convert D's string to big endian? How to convert to D's string from big endian? UTF-8 is always big emdian. oops, what? Q: Is the UTF-8 encoding scheme the same

How to place char* of stringZ to ubyte[]?

2012-10-29 Thread denizzzka
immutable ubyte[] valueBin = cast(immutable(ubyte[])) toStringz(s); // s is string type Error: e2ir: cannot cast toStringz(s) of type immutable(char)* to type immutable(ubyte[])

Re: How to place char* of stringZ to ubyte[]?

2012-10-29 Thread bearophile
denizzzka: immutable ubyte[] valueBin = cast(immutable(ubyte[])) toStringz(s); // s is string type Error: e2ir: cannot cast toStringz(s) of type immutable(char)* to type immutable(ubyte[]) One way to do it: import std.stdio; void main() { string s = hello; auto valueBin =

Re: How to place char* of stringZ to ubyte[]?

2012-10-29 Thread denizzzka
On Monday, 29 October 2012 at 17:51:56 UTC, bearophile wrote: denizzzka: immutable ubyte[] valueBin = cast(immutable(ubyte[])) toStringz(s); // s is string type Error: e2ir: cannot cast toStringz(s) of type immutable(char)* to type immutable(ubyte[]) One way to do it: import std.stdio;

Re: How to place char* of stringZ to ubyte[]?

2012-10-29 Thread bearophile
denizzzka: I am trying to send to remote host utf8 text with zero byte at end (required by protocol) What if your UTF8 string coming from D already contains several zeros? toStringz(s) returns a pointer, so you can't cast a pointer (that doesn't know the length the buffer it points to) to

Re: How to place char* of stringZ to ubyte[]?

2012-10-29 Thread denizzzka
On Monday, 29 October 2012 at 18:50:58 UTC, bearophile wrote: denizzzka: I am trying to send to remote host utf8 text with zero byte at end (required by protocol) What if your UTF8 string coming from D already contains several zeros? Incredible situation because it is text-based protocol

Re: Correct way to map C #define to version

2012-10-29 Thread Mike Wey
On 10/29/2012 03:14 PM, Regan Heath wrote: On Mon, 29 Oct 2012 13:47:46 -, Sumit Raja sumitr...@gmail.com wrote: On Monday, 29 October 2012 at 12:31:56 UTC, Regan Heath wrote: On Mon, 29 Oct 2012 11:31:33 -, Sumit Raja sumitr...@gmail.com wrote: Thanks both this works great for

Re: __traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Timon Gehr
On 10/29/2012 12:03 PM, Jonathan M Davis wrote: On Monday, October 29, 2012 11:42:59 Zhenya wrote: Hi! Tell me please,in this code first and second static if,are these equivalent? with arg = 1, __traits(compiles,check(arg);) = true, is(typeof(check(arg))) = false. In principle,

Re: crash suggestions

2012-10-29 Thread Ali Çehreli
On 10/29/2012 05:04 AM, Dan wrote: I have installed vibe and it requires libraries like ssl, event_pthreads, etc. I have those included in my command line. When I simply add the -m32 as suggested it can no longer find those lib files. Do I then need to track down 32 bit versions of each and

Re: __traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Jonathan M Davis
On Monday, October 29, 2012 23:38:34 Timon Gehr wrote: On 10/29/2012 12:03 PM, Jonathan M Davis wrote: On Monday, October 29, 2012 11:42:59 Zhenya wrote: Hi! Tell me please,in this code first and second static if,are these equivalent? with arg = 1, __traits(compiles,check(arg);) =

Re: __traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Timon Gehr
On 10/30/2012 12:17 AM, Jonathan M Davis wrote: On Monday, October 29, 2012 23:38:34 Timon Gehr wrote: On 10/29/2012 12:03 PM, Jonathan M Davis wrote: On Monday, October 29, 2012 11:42:59 Zhenya wrote: Hi! Tell me please,in this code first and second static if,are these equivalent? with arg

Re: __traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Jonathan M Davis
On Tuesday, October 30, 2012 00:29:22 Timon Gehr wrote: On 10/30/2012 12:17 AM, Jonathan M Davis wrote: On Monday, October 29, 2012 23:38:34 Timon Gehr wrote: On 10/29/2012 12:03 PM, Jonathan M Davis wrote: On Monday, October 29, 2012 11:42:59 Zhenya wrote: Hi! Tell me please,in this

Re: __traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Timon Gehr
On 10/30/2012 01:43 AM, Jonathan M Davis wrote: On Tuesday, October 30, 2012 00:29:22 Timon Gehr wrote: On 10/30/2012 12:17 AM, Jonathan M Davis wrote: On Monday, October 29, 2012 23:38:34 Timon Gehr wrote: On 10/29/2012 12:03 PM, Jonathan M Davis wrote: On Monday, October 29, 2012 11:42:59

Re: __traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Jonathan M Davis
On Tuesday, October 30, 2012 02:22:42 Timon Gehr wrote: On 10/30/2012 01:43 AM, Jonathan M Davis wrote: On Tuesday, October 30, 2012 00:29:22 Timon Gehr wrote: On 10/30/2012 12:17 AM, Jonathan M Davis wrote: On Monday, October 29, 2012 23:38:34 Timon Gehr wrote: On 10/29/2012 12:03 PM,