Re: how to get the local?

2011-06-02 Thread Lloyd Dupont
Yes and no! On one hand I'm a fervent believer of all things Windows 7! :P On the other hand my (learning) D project is about writing an installer. Which should just work with no unexpected dependencies! I was telling to myself earlier today too that I should not use this function, just in cas

How to do "cast(ubyte[4])some_uint" in D1?

2011-06-02 Thread Nick Sabalausky
In D2, I can treat a uint as an array of ubytes by doing this: uint num = /+...whatever...+/; ubyte[] = cast(ubyte[4])num; How do I do that in D1? IIRC, D1 requires an explicit slice operator to convert from a static-array to a slice/dynamic-array, so I tried this: ubyte[] = (cast(ubyte[4])num

from .h to .d

2011-06-02 Thread Lloyd Dupont
let say there is a .h in the windows SDK I'm interested in (namely "msi.h"), is there a way to automatically translate it to a .d? I think I read about such a thing once... Thanks!

Re: How to do "cast(ubyte[4])some_uint" in D1?

2011-06-02 Thread bearophile
Nick Sabalausky: > In D2, I can treat a uint as an array of ubytes by doing this: > > uint num = /+...whatever...+/; > ubyte[] = cast(ubyte[4])num; > > How do I do that in D1? Using a union is probably the safest way: union Uint2Ubyte { uint u; ubyte[4] b; } By the way, this of type c

Re: How to do "cast(ubyte[4])some_uint" in D1?

2011-06-02 Thread Timon Gehr
> Nick Sabalausky: > >> In D2, I can treat a uint as an array of ubytes by doing this: >> >> uint num = /+...whatever...+/; >> ubyte[] = cast(ubyte[4])num; >> >> How do I do that in D1? > > Using a union is probably the safest way: > > union Uint2Ubyte { > uint u; > ubyte[4] b; > } > > By t

Re: How to do "cast(ubyte[4])some_uint" in D1?

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 05:35:40 -0400, Nick Sabalausky wrote: In D2, I can treat a uint as an array of ubytes by doing this: uint num = /+...whatever...+/; ubyte[] = cast(ubyte[4])num; How do I do that in D1? IIRC, D1 requires an explicit slice operator to convert from a static-array to a sl

Re: Memory corruption rant.

2011-06-02 Thread Kagamin
Jesse Phillips Wrote: > writeln("I'm still ok"); > writeln("2"); > if(myObject is null) > writeln("3"); > else > writeln("4"); > writeln(0); > writeln(false); > Prints everything up to 2. You should look at it in debugger at assembly level. There's no need to compile it with debug symbols,

Re: Memory corruption rant.

2011-06-02 Thread Kagamin
Kagamin Wrote: > Jesse Phillips Wrote: > > > writeln("I'm still ok"); > > writeln("2"); > > if(myObject is null) > > writeln("3"); > > else > > writeln("4"); > > writeln(0); > > writeln(false); > > > Prints everything up to 2. > > You should look at it in debugger at assembly level. There's

Re: Memory corruption rant.

2011-06-02 Thread Kagamin
Kagamin Wrote: > writeln("I'm still ok"); > asm > { > cmp EBP,0; > ja ok; > hlt; > ok: nop; > } > writeln("Still ok"); > if(myObject is null) >writeln("3"); > else >writeln("4"); without hlt: asm { cmp EBP,0; ja ok; call _msg; ok: nop; } extern(C) void msg() { writeln("msg hit");

Re: from .h to .d

2011-06-02 Thread Jesse Phillips
Lloyd Dupont Wrote: > let say there is a .h in the windows SDK I'm interested in (namely "msi.h"), > is there a way to automatically translate it to a .d? > I think I read about such a thing once... > > Thanks! > No. Though HtoD will do a pretty good job. It doesn't handle the preprocessor a

Re: from .h to .d

2011-06-02 Thread Lloyd Dupont
Thanks! It will be a good start! "Jesse Phillips" wrote in message news:is879j$b5q$1...@digitalmars.com... Lloyd Dupont Wrote: let say there is a .h in the windows SDK I'm interested in (namely "msi.h"), is there a way to automatically translate it to a .d? I think I read about such a thing

Infinite loop not working DMD2

2011-06-02 Thread Guillermo Estrada
Hi, been developing in D a lot but first time in news groups, I thought this might be the place. I'm trying to make a fork bomb in D (of course no fork cause target its windows platform) but anyway. I did one a while ago using D1 and Tango and all ran perfectly, I'm trying to migrate my whole dev

Re: Infinite loop not working DMD2

2011-06-02 Thread Brad Roberts
On 6/2/2011 8:43 AM, Guillermo Estrada wrote: > Hi, been developing in D a lot but first time in news groups, I > thought this might be the place. > > I'm trying to make a fork bomb in D (of course no fork cause target > its windows platform) but anyway. I did one a while ago using D1 and > Tango

Re: Infinite loop not working DMD2

2011-06-02 Thread Guillermo Estrada
> The exec* family of functions cause the new app to replace the current process. So after the execv, the loop doesn't exist. Any way to spawn the process without killing himself?

Re: Infinite loop not working DMD2

2011-06-02 Thread Ali Çehreli
On 06/02/2011 08:51 AM, Guillermo Estrada wrote: The exec* family of functions cause the new app to replace the current process. So after the execv, the loop doesn't exist. Any way to spawn the process without killing himself? Would std.process.system or std.process.shell work? Ali

Re: Infinite loop not working DMD2

2011-06-02 Thread Guillermo Estrada
== Quote from Ali Çehreli (acehr...@yahoo.com)'s article > On 06/02/2011 08:51 AM, Guillermo Estrada wrote: > >> The exec* family of functions cause the new app to replace the > > current process. So after the execv, the loop doesn't exist. > > > > Any way to spawn the process without killing hims

Re: Infinite loop not working DMD2

2011-06-02 Thread Jonathan M Davis
On 2011-06-02 08:59, Ali Çehreli wrote: > On 06/02/2011 08:51 AM, Guillermo Estrada wrote: > >> The exec* family of functions cause the new app to replace the > > > > current process. So after the execv, the loop doesn't exist. > > > > Any way to spawn the process without killing himself? > > W

array of constants?

2011-06-02 Thread Lloyd Dupont
I'm trying to define an array of constant like: === immutable string[int] MyDict = [ 1: "monday", 2: "tuesday", ]; And I keep having compiler error: Error1Error: non-constant expression [1:"monday",2:"tuesday"] C:\Dev\DTest\DTest1\Dexperiment\LCIDs.d9 what can I do?

Re: Infinite loop not working DMD2

2011-06-02 Thread Jonathan M Davis
On 2011-06-02 09:14, Guillermo Estrada wrote: > == Quote from Ali Çehreli (acehr...@yahoo.com)'s article > > > On 06/02/2011 08:51 AM, Guillermo Estrada wrote: > > >> The exec* family of functions cause the new app to replace the > > > > > > current process. So after the execv, the loop doesn't

Re: array of constants?

2011-06-02 Thread Etherous
You need to set it in a static constructor immutable string[int] MyDict; static this () { MyDict = cast(string[int]) [ 1: "monday", 2: "tuesday" ]; }

Re: Infinite loop not working DMD2

2011-06-02 Thread Guillermo Estrada
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > On 2011-06-02 09:14, Guillermo Estrada wrote: > > == Quote from Ali Çehreli (acehr...@yahoo.com)'s article > > > > > On 06/02/2011 08:51 AM, Guillermo Estrada wrote: > > > >> The exec* family of functions cause the new app to replace

Re: Infinite loop not working DMD2

2011-06-02 Thread Guillermo Estrada
> So, if you can't find something that really seems like it should > be in Phobos, open an enhancement request on it on bugzilla: > d.puremagic.com/issues/ > Jonathan M Davis As expected spawnvp() creates child process that exit with the father, just as system(). exec*() replaces the parent proces

16 byte alignment

2011-06-02 Thread Shahid
I'm working with 64bit iasm and I would like to have some constant data 16 byte aligned. I have near the top of my source file: __gshared immutable { ulong[2] sse_0F = [0x0F0F_0F0F_0F0F_0F0F,0x0F0F_0F0F_0F0F_0F0F]; ulong[2] sse_30 = [0x3030_3030_3030_3030,0x3030_3030_3030_3030];

private method in interface

2011-06-02 Thread Michael Shulman
Hi, The following code fails the linker, complaining about an undefined reference to 'foo': interface A { private int foo(); } class B { int bar(A x) { return x.foo(); } } void main() { } But if I remove the 'private' qualifier on 'foo', then it succeeds. Shouldn't B.bar() be able to acc

Re: Infinite loop not working DMD2

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 11:43:50 -0400, Guillermo Estrada wrote: Hi, been developing in D a lot but first time in news groups, I thought this might be the place. I'm trying to make a fork bomb in D (of course no fork cause target its windows platform) but anyway. I did one a while ago using D1 a

Re: private method in interface

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 13:10:14 -0400, Michael Shulman wrote: Hi, The following code fails the linker, complaining about an undefined reference to 'foo': interface A { private int foo(); } class B { int bar(A x) { return x.foo(); } } void main() { } But if I remove the 'private' quali

No index for cycle ranges

2011-06-02 Thread Andrej Mitrovic
import std.range; void main() { auto arr = [1, 2, 3, 4, 5, 6, 7, 8]; auto foo = cycle(arr); // nope foreach (int index, int val; foo) { } // nope foreach (int index, int val; take(foo, 5)) { } // ok foreach (int index, int val; tak

Re: Infinite loop not working DMD2

2011-06-02 Thread Guillermo Estrada
> std.process is woefully unmaintained. Lars K is developing a new version, > and I am really really late getting a windows version to him so it can be > included in phobos. It includes simple methods to create a sub- process, > which should solve your issue. > I think this shall be my next "Spar

Re: No index for cycle ranges

2011-06-02 Thread bearophile
Andrej Mitrovic: > Is this because cycle is an infinite range, and index might overflow? The cause is different: cycle is a range, and they don't define an counter variable. With opApply sometimes you define the counter too. The compiler doesn't create a counter variable for free. Bye, bearoph

Re: private method in interface

2011-06-02 Thread Michael Shulman
On Thu, Jun 2, 2011 at 10:31 AM, Steven Schveighoffer wrote: > Private methods are non-virtual, so I'm pretty sure they are not supposed to > be allowed in an interface. > > But I suppose private could also mean private final, in which case you have > to provide an implementation for foo in the in

Re: private method in interface

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 15:01:31 -0400, Michael Shulman wrote: On Thu, Jun 2, 2011 at 10:31 AM, Steven Schveighoffer wrote: Private methods are non-virtual, so I'm pretty sure they are not supposed to be allowed in an interface. But I suppose private could also mean private final, in which c

Re: private method in interface

2011-06-02 Thread Jonathan M Davis
On 2011-06-02 12:01, Michael Shulman wrote: > On Thu, Jun 2, 2011 at 10:31 AM, Steven Schveighoffer > > wrote: > > Private methods are non-virtual, so I'm pretty sure they are not supposed > > to be allowed in an interface. > > > > But I suppose private could also mean private final, in which ca

Re: No index for cycle ranges

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 14:17:26 -0400, Andrej Mitrovic wrote: import std.range; void main() { auto arr = [1, 2, 3, 4, 5, 6, 7, 8]; auto foo = cycle(arr); // nope foreach (int index, int val; foo) { } // nope foreach (int index, int val; take(foo, 5)) { } /

Re: private method in interface

2011-06-02 Thread Michael Shulman
On Thu, Jun 2, 2011 at 12:20 PM, Jonathan M Davis wrote: > http://d.puremagic.com/issues/show_bug.cgi?id=4542 > http://d.puremagic.com/issues/show_bug.cgi?id=2051 Thank you! I think this answers my question completely; I just need to change "private" to "protected". Is there a place on the web

Re: How to do "cast(ubyte[4])some_uint" in D1?

2011-06-02 Thread Nick Sabalausky
"Timon Gehr" wrote in message news:is7ojo$2ggv$1...@digitalmars.com... >> Nick Sabalausky: >> >>> In D2, I can treat a uint as an array of ubytes by doing this: >>> >>> uint num = /+...whatever...+/; >>> ubyte[] = cast(ubyte[4])num; >>> >>> How do I do that in D1? >> >> Using a union is probably

Re: How to do "cast(ubyte[4])some_uint" in D1?

2011-06-02 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:is8qu8$1cq3$1...@digitalmars.com... > "Timon Gehr" wrote in message > news:is7ojo$2ggv$1...@digitalmars.com... >>> Nick Sabalausky: >>> In D2, I can treat a uint as an array of ubytes by doing this: uint num = /+...whatever...+/; ubyte

wstring always 2-byte aligned?

2011-06-02 Thread Nick Sabalausky
I found a user comment on an MDSN Windows API reference page (Which I've since lost, but I think it was somewhere in the Registry section.) that claims that the Unicode-taking functions in the Windows API (or at least some of them) require the unicode strings to be aligned on a two-byte boundar

Re: wstring always 2-byte aligned?

2011-06-02 Thread Andrej Mitrovic
Maybe they mean UCS-2? I know that for example Charles Petzold's Programming Windows book assumes that UTF16 characters are *always* 2 bytes wide. So maybe that has something to do with that alignment requirement.

Re: private method in interface

2011-06-02 Thread Jonathan M Davis
On 2011-06-02 12:59, Michael Shulman wrote: > On Thu, Jun 2, 2011 at 12:20 PM, Jonathan M Davis wrote: > > http://d.puremagic.com/issues/show_bug.cgi?id=4542 > > http://d.puremagic.com/issues/show_bug.cgi?id=2051 > > Thank you! I think this answers my question completely; I just need > to change

Re: No index for cycle ranges

2011-06-02 Thread Andrej Mitrovic
Well actually all I wanted was a counter variable. I can put the thing in a for loop or while loop, but I thought that a counter variable is something that the compiler can always add without too much thinking. I guess things aren't so simple.

Re: wstring always 2-byte aligned?

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 16:53:12 -0400, Nick Sabalausky wrote: I found a user comment on an MDSN Windows API reference page (Which I've since lost, but I think it was somewhere in the Registry section.) that claims that the Unicode-taking functions in the Windows API (or at least some of them) requ

Re: wstring always 2-byte aligned?

2011-06-02 Thread Andrej Mitrovic
Btw there's .alignof for these things, which will return 2 bytes.

Re: No index for cycle ranges

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 17:38:38 -0400, Andrej Mitrovic wrote: Well actually all I wanted was a counter variable. I can put the thing in a for loop or while loop, but I thought that a counter variable is something that the compiler can always add without too much thinking. I guess things aren't

Re: No index for cycle ranges

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 17:38:38 -0400, Andrej Mitrovic wrote: Well actually all I wanted was a counter variable. I can put the thing in a for loop or while loop, but I thought that a counter variable is something that the compiler can always add without too much thinking. Also, BTW, you can st

Re: No index for cycle ranges

2011-06-02 Thread Andrej Mitrovic
On 6/2/11, Steven Schveighoffer wrote: > On Thu, 02 Jun 2011 17:38:38 -0400, Andrej Mitrovic > wrote: > >> Well actually all I wanted was a counter variable. I can put the thing >> in a for loop or while loop, but I thought that a counter variable is >> something that the compiler can always add

Re: No index for cycle ranges

2011-06-02 Thread Steven Schveighoffer
On Thu, 02 Jun 2011 18:01:21 -0400, Andrej Mitrovic wrote: On 6/2/11, Steven Schveighoffer wrote: On Thu, 02 Jun 2011 17:38:38 -0400, Andrej Mitrovic wrote: Well actually all I wanted was a counter variable. I can put the thing in a for loop or while loop, but I thought that a counter va

Re: No index for cycle ranges

2011-06-02 Thread bearophile
Steven Schveighoffer: > So I'm not sure how this would be solved, but it's definitely complicated. To solve this problem Python uses the enumerate function: >>> for c in "abc": ... print c ... a b c >>> for i,c in enumerate("abc"): ... print i, c ... 0 a 1 b 2 c In D it's easy to create som

Re: private method in interface

2011-06-02 Thread Michael Shulman
Thanks! On Thu, Jun 2, 2011 at 2:36 PM, Jonathan M Davis wrote: > On 2011-06-02 12:59, Michael Shulman wrote: >> On Thu, Jun 2, 2011 at 12:20 PM, Jonathan M Davis > wrote: >> > http://d.puremagic.com/issues/show_bug.cgi?id=4542 >> > http://d.puremagic.com/issues/show_bug.cgi?id=2051 >> >> Thank

Re: private method in interface

2011-06-02 Thread Kagamin
Jonathan M Davis Wrote: > http://d.puremagic.com/issues/show_bug.cgi?id=4542 > http://d.puremagic.com/issues/show_bug.cgi?id=2051 Nothing prevents compiler from considering class private methods as final and allow implement interface private methods (possibly with requirement for `override` key

Re: private method in interface

2011-06-02 Thread Jonathan M Davis
On 2011-06-02 23:53, Kagamin wrote: > Jonathan M Davis Wrote: > > http://d.puremagic.com/issues/show_bug.cgi?id=4542 > > http://d.puremagic.com/issues/show_bug.cgi?id=2051 > > Nothing prevents compiler from considering class private methods as final > and allow implement interface private methods