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/201

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 Z

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! > > >>>

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 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,

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

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, is(typeof(co

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 wrote: On Monday, 29 October 2012 at 12:31:56 UTC, Regan Heath wrote: On Mon, 29 Oct 2012 11:31:33 -, Sumit Raja wrote: Thanks both this works great for structs. Anything similar I can do for enums?

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: 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 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; v

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 = cast(i

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: 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 probl

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 irrespe

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. std.file.FileExce

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: 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 Adam D. Ruppe
UTF-8 isn't affected by endianness.

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: Correct way to map C #define to version

2012-10-29 Thread Regan Heath
On Mon, 29 Oct 2012 13:47:46 -, Sumit Raja wrote: On Monday, 29 October 2012 at 12:31:56 UTC, Regan Heath wrote: On Mon, 29 Oct 2012 11:31:33 -, Sumit Raja wrote: Thanks both this works great for structs. Anything similar I can do for enums? Example? (The C/C++ code you're trying

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 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 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 help... One example here

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 Regan Heath
On Mon, 29 Oct 2012 11:31:33 -, Sumit Raja 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: 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 be

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 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(failur

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 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 simple enum + static if is e

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

__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: 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 Car

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 h