Re: writef: How to output hex byte?

2010-08-28 Thread torhu
On 29.08.2010 07:06, Nick Sabalausky wrote: ubyte myByte = 0x09; writef("%%%.2X", myByte); writef("%%%02X", myByte); On codepad.org (DMD 1.026 last time I checked), this prints this: %09%09 So it's probably a bug in the new formatting code. I assume it's supposed to follow the C behavior in

Re: writef: How to output hex byte?

2010-08-28 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:i5cnrn$30h...@digitalmars.com... > I'm having trouble understanding the docs on this. From what I could tell, > it seemed like both of these should work: > > writef("%.2X", myByte); > writef("%02X", myByte); > > But both of them just simply print the forma

writef: How to output hex byte?

2010-08-28 Thread Nick Sabalausky
I'm having trouble understanding the docs on this. From what I could tell, it seemed like both of these should work: writef("%.2X", myByte); writef("%02X", myByte); But both of them just simply print the format string as-is.

Re: built-in string hash ?

2010-08-28 Thread BCS
Hello bearophile, Pelle: I doubt that gives any performance gains. typeid(a).getHash should be a constant expression anyway, and I don't see any gains in my tiny benchmark test. My code shows a limited time difference: import std.stdio: writeln; import std.date: getUTCtime, ticksPerSecond;

Re: built-in string hash ?

2010-08-28 Thread bearophile
Pelle: > I doubt that gives any performance gains. typeid(a).getHash should be a > constant expression anyway, and I don't see any gains in my tiny > benchmark test. My code shows a limited time difference: import std.stdio: writeln; import std.date: getUTCtime, ticksPerSecond; void main() {

Re: Memory management and garbage collectors

2010-08-28 Thread bearophile
JMRyan: > In theory, garbage collectors make memory leaks a thing of the past. Even with a perfect GC you may leave around references that keep alive some data that you will never need to use. This is a kind of memory leak. And the current D GC is not fully precise, this means that sometimes it

Memory management and garbage collectors

2010-08-28 Thread JMRyan
In theory, garbage collectors make memory leaks a thing of the past. In practice, garbage collectors don't always work according to theory. This makes me curious: how does one test for memory leaks in a D program? I also don't know how smart or dumb garbage collectors are. How much help doe

Re: built-in string hash ?

2010-08-28 Thread Pelle
On 08/28/2010 10:25 PM, bearophile wrote: torhu: string a = "abc"; auto hash = typeid(a).getHash(&a); If higher performance is necessary, you may pre-compute part of that: void main() { string a = "abc"; auto hash1 = typeid(a).getHash(&a); auto stringHash =&(typeid(a).getHash);

Re: built-in string hash ?

2010-08-28 Thread bearophile
torhu: > string a = "abc"; > auto hash = typeid(a).getHash(&a); If higher performance is necessary, you may pre-compute part of that: void main() { string a = "abc"; auto hash1 = typeid(a).getHash(&a); auto stringHash = &(typeid(a).getHash); auto hash2 = stringHash(&a); assert

Re: void[] vs byte[]

2010-08-28 Thread BCS
Hello Yao G., I'm here with another n00b question: When dealing with big buffers (or files), which is better to use as storage? void[] or byte[]? If the data may contain pointers into the heap, use void[] if it will not use byte[]. byte[] is "raw" data, void[] is anything at all. What a

void[] vs byte[]

2010-08-28 Thread Yao G.
I'm here with another n00b question: When dealing with big buffers (or files), which is better to use as storage? void[] or byte[]? What are the advantages and disadvantages of each one? I've seen that void[] is used in some Phobos modules, like std.zlib, and in other modules the choice i

Re: Ways to initialize static arrays

2010-08-28 Thread Stanislav Blinov
Done: http://d.puremagic.com/issues/show_bug.cgi?id=4745

Re: built-in string hash ?

2010-08-28 Thread torhu
On 28.08.2010 16:37, Kevin Bailey wrote: So I have a class containing two strings: class Foo { string s1, s2; ... and I'd like to add a toHash() member, but I can't find the built-in string hash function. These don't work: s1.toHash() s1.toHash s1.hash s1.hash() hash(s1) yet

built-in string hash ?

2010-08-28 Thread Kevin Bailey
So I have a class containing two strings: class Foo { string s1, s2; ... and I'd like to add a toHash() member, but I can't find the built-in string hash function. These don't work: s1.toHash() s1.toHash s1.hash s1.hash() hash(s1) yet strings can clearly be the key in a map. I

Re: Compiling Windows GUI-application

2010-08-28 Thread Mike James
"Fab" wrote in message news:i59i02$9...@digitalmars.com... > Thank you. I am using > my mobile phone to > answer so it's pretty > hard. I will try your > tips later. > > ps: i wanted to say > that delphi is slow > and it seems to be > old. in addition the > bindings for sdl, > allegro and so on a