Re: get address of object if opCast is overridden

2012-11-30 Thread Jonathan M Davis
On Saturday, December 01, 2012 03:05:00 js.mdnq wrote: > Let O be an object with opCast overridden, then > > > writeln(O); //prints string > writeln(cast(void *)O)) // error, works fine if I comment out the > opCast override > writeln(&O) // address of pointer to O, not what I want. > > I want t

get address of object if opCast is overridden

2012-11-30 Thread js.mdnq
Let O be an object with opCast overridden, then writeln(O); //prints string writeln(cast(void *)O)) // error, works fine if I comment out the opCast override writeln(&O) // address of pointer to O, not what I want. I want to compare a few objects based on their location. (I know this is bad

Re: alias this

2012-11-30 Thread js.mdnq
I'm running into an issue of trying to get back the normal this pointer ;/ If I so `alias a this;` how do I get the pointer to the object back for other purposes?

Re: Compile And Run in emacs

2012-11-30 Thread Timon Gehr
On 12/01/2012 12:13 AM, Aytug wrote: So I have installed dmd, gdc, emacs and d-mode.el on my Debian machine. I can compile the program fine with M-compile. The problem starts after that. I cannot run the output file properly from within emacs. Either there is a way and I cannot find it, or ther

Re: Compile And Run in emacs

2012-11-30 Thread Dan
On Friday, 30 November 2012 at 23:13:10 UTC, Aytug wrote: So I have installed dmd, gdc, emacs and d-mode.el on my Debian machine. I can compile the program fine with M-compile. The problem starts after that. I cannot run the output file properly from within emacs. Either there is a way and I

Compile And Run in emacs

2012-11-30 Thread Aytug
So I have installed dmd, gdc, emacs and d-mode.el on my Debian machine. I can compile the program fine with M-compile. The problem starts after that. I cannot run the output file properly from within emacs. Either there is a way and I cannot find it, or there really is no way. What I try instea

Re: prune with dirEntries

2012-11-30 Thread Dan
On Friday, 30 November 2012 at 19:52:26 UTC, Jonathan M Davis wrote: If you're compiling with -property, filter must have the parens for the function call as it's a function, not a property. The !() is for the template arguments and is separate from the parens for the function call. That mean

Re: alias this

2012-11-30 Thread js.mdnq
On Friday, 30 November 2012 at 21:46:47 UTC, Rob T wrote: On Friday, 30 November 2012 at 14:14:36 UTC, js.mdnq wrote: On Friday, 30 November 2012 at 14:02:42 UTC, Andrej Mitrovic wrote: On 11/30/12, js.mdnq wrote: alias t this; This should explain: http://dlang.org/class.html#AliasThis Th

Re: alias this

2012-11-30 Thread Rob T
On Friday, 30 November 2012 at 14:14:36 UTC, js.mdnq wrote: On Friday, 30 November 2012 at 14:02:42 UTC, Andrej Mitrovic wrote: On 11/30/12, js.mdnq wrote: alias t this; This should explain: http://dlang.org/class.html#AliasThis Thanks, I'm sure I saw that at some point but I guess it just

Re: prune with dirEntries

2012-11-30 Thread Joshua Niehus
On Friday, 30 November 2012 at 19:52:26 UTC, Jonathan M Davis wrote: If you're compiling with -property, filter must have the parens for the function call as it's a function, not a property. The !() is for the template arguments and is separate from the parens for the function call. That means

Re: prune with dirEntries

2012-11-30 Thread Jonathan M Davis
On Friday, November 30, 2012 13:02:50 Dan wrote: > On Friday, 30 November 2012 at 07:29:59 UTC, Joshua Niehus wrote: > > On Friday, 30 November 2012 at 06:29:01 UTC, Joshua Niehus > > > > wrote: > >> I think if you go breadth first, you can filter out the > >> unwanted directories before it delves

Re: Linker error

2012-11-30 Thread RenatoUtsch
On Friday, 30 November 2012 at 19:09:12 UTC, Maxim Fomin wrote: On Friday, 30 November 2012 at 18:44:31 UTC, RenatoUtsch wrote: $ dmd testReturn.d ... because you didn't compiled the second file. Man, I was going to say that it didn't work, that I tested it before, but then I noticed that

Re: Linker error

2012-11-30 Thread Maxim Fomin
On Friday, 30 November 2012 at 18:44:31 UTC, RenatoUtsch wrote: $ dmd testReturn.d ... because you didn't compiled the second file.

Re: prune with dirEntries

2012-11-30 Thread Dmitry Olshansky
11/30/2012 11:29 AM, Joshua Niehus пишет: On Friday, 30 November 2012 at 06:29:01 UTC, Joshua Niehus wrote: I think if you go breadth first, you can filter out the unwanted directories before it delves into them oh wait... it probably still looks through all those dir's. What about this? impo

Re: Apparent problem with GC not collecting on Windows

2012-11-30 Thread Dmitry Olshansky
11/30/2012 12:36 AM, Ali Çehreli пишет: On 11/29/2012 12:06 PM, Michael wrote: >> Because you used uint instead of ubyte, array is bigger, memory >> exhausts faster. > Oh, I see. > >>> 3. Why it helps? >>> GC.free(data.ptr); >> >> Initial leak happened because for some reason array alloc

Linker error

2012-11-30 Thread RenatoUtsch
Hello, I was trying to play with modules and import, but I couldn't understand why this code is giving linker errors: /classy/widget.d module classy.widget; class ReturnItself { public ref ReturnItself returnItself() { return this;

Re: prune with dirEntries

2012-11-30 Thread Joshua Niehus
On Friday, 30 November 2012 at 12:02:51 UTC, Dan wrote: Good idea, thanks. I could not get original to compile as is - but the concept is just what was needed. I got an error on line 8: Error: not a property dirEntries(path, cast(SpanMode)0, true).filter!(__lambda2) I'm using a quite recent ve

Re: How can I store delegates in array?

2012-11-30 Thread Chopin
Amazing! It works! Thank you so much :)

Re: How can I store delegates in array?

2012-11-30 Thread H. S. Teoh
On Fri, Nov 30, 2012 at 04:57:44PM +0100, Chopin wrote: > I tried the following: > > import std.stdio; > import std.regex; > > bool lol(string name, string val) > { > if (name == "lal") > if (val[0..3] == "2124") > return true; > return false; > } > > bool lal(string

Re: How can I store delegates in array?

2012-11-30 Thread Chopin
I tried the following: import std.stdio; import std.regex; bool lol(string name, string val) { if (name == "lal") if (val[0..3] == "2124") return true; return false; } bool lal(string name, string val) { return false; } alias bool delegate(string, string) DgType; voi

Re: How can I store delegates in array?

2012-11-30 Thread H. S. Teoh
On Fri, Nov 30, 2012 at 04:41:40PM +0100, Chopin wrote: > Hi! > > I've never used delegates before etc. not really familiar with it. [...] You could try something like this: alias bool delegate(string, string) DgType; DgType[] arrayOfDelegates; T -- Why waste time learning, w

How can I store delegates in array?

2012-11-30 Thread Chopin
Hi! I've never used delegates before etc. not really familiar with it. I was trying something like this: import std.stdio; import std.regex; bool lol(string name, string val) { if (name == "lal") if (val[0..3] == "2124") return true; return false; } bool lal(string

Re: Templated Function pointers

2012-11-30 Thread bearophile
js.mdnq: It seems one can accomplish this using delegates assigned by generic functions. If you care so much for performance, when you work with D delegates it's useful to know the difference between static/scope delegates (that are just a fat pointer) and closures (that often induce a heap

Re: alias this

2012-11-30 Thread js.mdnq
On Friday, 30 November 2012 at 14:02:42 UTC, Andrej Mitrovic wrote: On 11/30/12, js.mdnq wrote: alias t this; This should explain: http://dlang.org/class.html#AliasThis Thanks, I'm sure I saw that at some point but I guess it just didn't sink in. This seems really cool and might solve a pr

alias this

2012-11-30 Thread js.mdnq
I've seen this technique pop up in several things and I'm curious to what it is/how it's used? alias t this; does what? It seems like it's used as a way to "trick" the compiler into doing some cool/useful things?

Re: Templated Function pointers

2012-11-30 Thread js.mdnq
It seems one can accomplish this using delegates assigned by generic functions. The delegate will end hold holding the "state" of the function. It sort of acts like a binder. It seems to work but more testing needs to be done. I'm not sure how efficient it is or if there is a better way but bas

Re: Type converter from build in to user type

2012-11-30 Thread js.mdnq
On Friday, 30 November 2012 at 03:40:31 UTC, Ali Çehreli wrote: On 11/29/2012 07:24 PM, jerro wrote: On Friday, 30 November 2012 at 02:59:06 UTC, js.mdnq wrote: I have a struct I am trying convert from int's to the type. Since I can't add a opCast overload to an int I don't know how to do it.

Re: prune with dirEntries

2012-11-30 Thread Dan
On Friday, 30 November 2012 at 07:29:59 UTC, Joshua Niehus wrote: On Friday, 30 November 2012 at 06:29:01 UTC, Joshua Niehus wrote: I think if you go breadth first, you can filter out the unwanted directories before it delves into them Good idea, thanks. I could not get original to compile as