Re: dmd simple loop disassembly - redundant instruction?

2013-12-26 Thread Lionello Lunesu
On 12/25/13, 20:03, Ivan Kazmenko wrote: - L2C:mov-03D0900h[EDX*4][EBP],EDX movECX,EDX incEDX cmpEDX,0F4240h jbL2C - You should have said that all instructions are redundant :) Looks like the array got optimized out, but t

Re: Human stupidity or is this a regression?

2013-12-25 Thread Lionello Lunesu
On 12/26/13, 11:58, bearophile wrote: Lionello Lunesu: I could have sworn this used to work. Is my memory failing me, or was this a deliberate change at some point? Perhaps a regression? It's not a regression, it's a locked-in design mistake. Write it like this and try again: fore

Re: get address of object if opCast is overridden

2013-12-25 Thread Lionello Lunesu
On 12/2/12, 21:25, js.mdnq wrote: I'm not just comparing them but using them as a unique ID for the objects in an algorithm to prevent computing over the same object more than once. o.toHash() ?? (Which incidentally just casts the reference to a hash_t, exactly what you want to do.)

Human stupidity or is this a regression?

2013-12-25 Thread Lionello Lunesu
Perhaps should have written "and/or" in the subject line since the two are not mutually exclusive. I was showing off D to friends the other day: import std.stdio; void main() { foreach (d; "你好") writeln(d); } IIRC, this used to work fine, with the variable "d" getting deduced as "dchar

Re: File IO: C# streams VS iterators?

2013-11-07 Thread Lionello Lunesu
On 11/8/13, 8:57, DDD wrote: I was watching a dconf talk about porting C# code to D. One thing that came up was there isn't anything like C# streams for D. Walter said he thinks iterators (unless I remember wrong) is superior. The speaker agreed but said it isn't a drop in replacement so that is

Re: Static arrays passed by value..?

2010-08-07 Thread Lionello Lunesu
On 2010-08-07 9:26, simendsjo wrote: The spec for array says: Static arrays are value types. Unlike in C and D version 1, static arrays are passed to functions by value. Static arrays can also be returned by functions. I don't get the "static arrays are passed to functions by value" part. Here

Re: [static] [shared] [const|immutable]

2009-05-18 Thread Lionello Lunesu
BCS wrote: Hello Lionello, "Christopher Wright" wrote in message The point of a shared local variable is to pass it to another thread or set of threads, which will then be able to mutate it without trouble. As before, how can an int (value type) on the stack ever be shared with another thr

Re: [static] [shared] [const|immutable]

2009-05-18 Thread Lionello Lunesu
Christopher Wright wrote: Lionello Lunesu wrote: "Christopher Wright" wrote in message news:gugs7b$70...@digitalmars.com... Lionello Lunesu wrote: I like shared/const/immutable as much as the next guy, but there are now 2x2x3=12 ways to decorate a variable. Furthermore,

Re: [static] [shared] [const|immutable]

2009-05-14 Thread Lionello Lunesu
"Christopher Wright" wrote in message news:gugs7b$70...@digitalmars.com... Lionello Lunesu wrote: I like shared/const/immutable as much as the next guy, but there are now 2x2x3=12 ways to decorate a variable. Furthermore, by either declaring the variable globally or locally (stac

[static] [shared] [const|immutable]

2009-05-14 Thread Lionello Lunesu
I like shared/const/immutable as much as the next guy, but there are now 2x2x3=12 ways to decorate a variable. Furthermore, by either declaring the variable globally or locally (stack), we end up with 24 possible declaration. See the code at the end of this post. Surely, some combinations shou

Re: enum to string

2009-03-12 Thread Lionello Lunesu
"Brad Roberts" wrote in message news:alpine.deb.2.00.0903121755240.4...@bellevue.puremagic.com... That said, I don't think this really helps the desired usecase much. It's useful, don't get me wrong, but still requires code to build up the bi-directional translations. Or am I missing somethi

Re: enum to string

2009-03-12 Thread Lionello Lunesu
//src\dmd\mtype.c, line 5025 (in TypeEnum::dotExp, after the #endif): /* If e.tupleof */ if (ident == Id::tupleof) { /* Create a TupleExp out of the fields of the struct e: * (e.field0, e.field1, e.field2, ...) */ e = e->semantic(sc); // do this before turning o

Re: enum to string

2009-03-12 Thread Lionello Lunesu
Nick Sabalausky wrote: "Lionello Lunesu" wrote in message news:gpc4j3$30a...@digitalmars.com... Oops, sorry, I didn't notice this was the .learn newsgroup. I guess a patch to the DMD source was not really what you expected. I just got so anxious! L. Hey, solutions are s

Re: enum to string

2009-03-12 Thread Lionello Lunesu
cr*p, I've pasted too little. Try this one instead.. I'll use a proper diff tool next time.. /* If e.tupleof */ if (ident == Id::tupleof) { /* Create a TupleExp out of the fields of the struct e: * (e.field0, e.field1, e.field2, ..

Re: enum to string

2009-03-12 Thread Lionello Lunesu
Your attachment is zero-byte. Oops... Try this one.. /* Create a TupleExp out of the fields of the struct e: * (e.field0, e.field1, e.field2, ...) */ e = e->semantic(sc);// do this before turning on noaccesscheck

Re: enum to string

2009-03-12 Thread Lionello Lunesu
Oops, sorry, I didn't notice this was the .learn newsgroup. I guess a patch to the DMD source was not really what you expected. I just got so anxious! L.

Re: enum to string

2009-03-12 Thread Lionello Lunesu
Nick Sabalausky wrote: Is there any way to do this (preferably in D1) with reflection? (ie, without having to manually create a conversion func/lookup for every value of every enum.) -- enum Shape { Square, Circle } char[] foo(Shape s) { // ? } // Either one of