Re: this compare not using opCmp?

2012-04-29 Thread Jonathan M Davis
On Monday, April 30, 2012 07:28:16 Era Scarecrow wrote: > On Monday, 30 April 2012 at 05:22:56 UTC, Jonathan M Davis wrote: > > == uses opEquals, not opCmp. It's using Object's opEquals, > > which does a > > comparison of the references, so it's true when comparing the > > exact same > > object and

Re: this compare not using opCmp?

2012-04-29 Thread Era Scarecrow
On Monday, 30 April 2012 at 05:22:56 UTC, Jonathan M Davis wrote: == uses opEquals, not opCmp. It's using Object's opEquals, which does a comparison of the references, so it's true when comparing the exact same object and false otherwise. Ahhh of course. Personally I think opCmp includes o

Re: struct to/from void, object to/from void

2012-04-29 Thread Era Scarecrow
On Monday, 30 April 2012 at 05:07:04 UTC, Ali Çehreli wrote: You mean "object"? A class variable is just a handle to the class object. Class variables are implemented as pointers, so yes, they will be the size of a pointer. Since I suspect that the pointers are 4 bytes on the OP's 32-bit system

Re: this compare not using opCmp?

2012-04-29 Thread Jonathan M Davis
On Monday, April 30, 2012 07:09:46 Era Scarecrow wrote: > In some code I'm working on, my asserted when I've confirmed it > was correct. With the opCmp() overridden. 'this' refers to the > current object, so why doesn't the first one succeed? > > class X { >int z; > >this(int xx) { >

this compare not using opCmp?

2012-04-29 Thread Era Scarecrow
In some code I'm working on, my asserted when I've confirmed it was correct. With the opCmp() overridden. 'this' refers to the current object, so why doesn't the first one succeed? class X { int z; this(int xx) { z = xx; } override int opCmp(Object y){ X x = cast(X)

Re: struct to/from void, object to/from void

2012-04-29 Thread Ali Çehreli
On 04/29/2012 06:01 PM, Era Scarecrow wrote: > On Monday, 30 April 2012 at 00:28:15 UTC, Jason King wrote: >> myobject.sizeof returns 4 (in 32 bit DMD) for every object I've >> tested, so I'm inclined to suspect its a bog-standard pointer, >> just what I'm looking to save and retrieve. >> Anybody

Re: -lib question(s)

2012-04-29 Thread Joshua Niehus
On Monday, 30 April 2012 at 02:49:21 UTC, Jesse Phillips wrote: However you also will need to specify the library you want to load: -L-lworld More detail. [snip] Hi Jesse, Thanks for the help, that was informative! I didn't realize I needed the load command (-L-lworld) and so I was trying t

Re: -lib question(s)

2012-04-29 Thread Jesse Phillips
On Saturday, 28 April 2012 at 05:37:20 UTC, Joshua Niehus wrote: Q1) The template version of hello seems to work, but the simpleton version doesn't. What am i missing? Q2) Shouldn't I be compiling world.d with -lib and then put world.a in some linker directory? I did that but got nowhere fas

Re: type conversions

2012-04-29 Thread Jonathan M Davis
On Monday, April 30, 2012 01:42:38 WhatMeWorry wrote: > I'm trying to get my head around D's type conversion. What is the > best way to convert a string to a char array? Or I should say is > this the best way? > > string s = "Hello There"; > char[] c; > > c = string.dup; dup will return a mutabl

Re: struct to/from void, object to/from void

2012-04-29 Thread Era Scarecrow
On Monday, 30 April 2012 at 00:28:15 UTC, Jason King wrote: myobject.sizeof returns 4 (in 32 bit DMD) for every object I've tested, so I'm inclined to suspect its a bog-standard pointer, just what I'm looking to save and retrieve. Anybody else want to chime in? I'd say that's right and wrong.

Re: struct to/from void, object to/from void

2012-04-29 Thread Jason King
Thanks for the rapid reply. void* opCast() { return &this; } Honestly, in my opinion, drop this. Don't make it more 'pointer-like'. Unless there's a good reason, or it makes sense (Mathematical), then don't. You keep having half the tests using regular &(address) operator; wha

Re: type conversions

2012-04-29 Thread Era Scarecrow
On Sunday, 29 April 2012 at 23:42:39 UTC, WhatMeWorry wrote: I'm trying to get my head around D's type conversion. What is the best way to convert a string to a char array? Or I should say is this the best way? string s = "Hello There"; char[] c; c = string.dup; Also, what is the best way to

Re: type conversions

2012-04-29 Thread Andrej Mitrovic
On 4/30/12, WhatMeWorry wrote: > I'm trying to get my head around D's type conversion. What is the > best way to convert a string to a char array? Or I should say is > this the best way? > > string s = "Hello There"; > char[] c; > > c = string.dup; > Well it depends . Why do you need a char[]? If

type conversions

2012-04-29 Thread WhatMeWorry
I'm trying to get my head around D's type conversion. What is the best way to convert a string to a char array? Or I should say is this the best way? string s = "Hello There"; char[] c; c = string.dup; Also, what is the best way to explicitly convert a string to an int? I've been looking at L

Re: struct to/from void, object to/from void

2012-04-29 Thread Era Scarecrow
On Sunday, 29 April 2012 at 22:35:19 UTC, Jason King wrote: I'm another of what seem to be legions of people trying to interface with OS stores that keep void * in c/c++. My particular one is Windows TLSData, but for my example I don't need any Windows code, just D. void* opCast() {

struct to/from void, object to/from void

2012-04-29 Thread Jason King
I'm another of what seem to be legions of people trying to interface with OS stores that keep void * in c/c++. My particular one is Windows TLSData, but for my example I don't need any Windows code, just D. // this based on code I snagged from this group // DMD 2.059 Win 7 Home Premium 64 bit.

Re: restrict alias this?

2012-04-29 Thread Namespace
On Sunday, 29 April 2012 at 17:29:03 UTC, Simen Kjaeraas wrote: On Sun, 29 Apr 2012 14:28:05 +0200, Namespace wrote: On Sunday, 29 April 2012 at 11:24:00 UTC, Simen Kjaeraas wrote: On Sun, 29 Apr 2012 10:14:09 +0200, Namespace wrote: Based on my previous thread (http://forum.dlang.org/th

Re: restrict alias this?

2012-04-29 Thread Simen Kjaeraas
On Sun, 29 Apr 2012 14:28:05 +0200, Namespace wrote: On Sunday, 29 April 2012 at 11:24:00 UTC, Simen Kjaeraas wrote: On Sun, 29 Apr 2012 10:14:09 +0200, Namespace wrote: Based on my previous thread (http://forum.dlang.org/thread/rpcqefmyqigftxsgs...@forum.dlang.org), I got the questi

Re: mysql binding/wrapper?

2012-04-29 Thread dnewbie
On Saturday, 28 April 2012 at 15:30:13 UTC, simendsjo wrote: stuff/blob/master/mysql.d http://my.opera.com/run3/blog/2012/03/13/d-mysql I use it in a bank account application. It works.

Re: cannot cast

2012-04-29 Thread Namespace
On Sunday, 29 April 2012 at 14:40:55 UTC, Jesse Phillips wrote: On Saturday, 28 April 2012 at 14:21:32 UTC, Namespace wrote: I finished my Ref/NotNull struct, but i've got a problem: If i try to cast the class, which should implicit convert to Ref!(Type) with alias this, i get the following err

Re: cannot cast

2012-04-29 Thread Jesse Phillips
On Saturday, 28 April 2012 at 14:21:32 UTC, Namespace wrote: I finished my Ref/NotNull struct, but i've got a problem: If i try to cast the class, which should implicit convert to Ref!(Type) with alias this, i get the following error message: "cannot cast a1.getRef("Ref.d",72u) of type Ref!(A) t

Re: restrict alias this?

2012-04-29 Thread Namespace
On Sunday, 29 April 2012 at 11:24:00 UTC, Simen Kjaeraas wrote: On Sun, 29 Apr 2012 10:14:09 +0200, Namespace wrote: Based on my previous thread (http://forum.dlang.org/thread/rpcqefmyqigftxsgs...@forum.dlang.org), I got the question whether it is possible to restrict "alias this"? Similar

Re: restrict alias this?

2012-04-29 Thread Simen Kjaeraas
On Sun, 29 Apr 2012 10:14:09 +0200, Namespace wrote: Based on my previous thread (http://forum.dlang.org/thread/rpcqefmyqigftxsgs...@forum.dlang.org), I got the question whether it is possible to restrict "alias this"? Similar to templates function, e.g. "void foo(T)(T value) if (isNumer

restrict alias this?

2012-04-29 Thread Namespace
Based on my previous thread (http://forum.dlang.org/thread/rpcqefmyqigftxsgs...@forum.dlang.org), I got the question whether it is possible to restrict "alias this"? Similar to templates function, e.g. "void foo(T)(T value) if (isNumeric!(T) ...", but it should be limited here so that it does