Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Jacob Carlborg
On 2011-08-03 20:36, Andrej Mitrovic wrote: On 8/3/11, Jacob Carlborg wrote: Why would you want to slow down framerate? Because the examples were written in the 90s and CPUs and graphic cards are so fast these days that the old code runs at an enormous framerate. I would say that the correc

Re: NaCl stable ABI

2011-08-03 Thread Nick Sabalausky
"Andrej Mitrovic" wrote in message news:mailman.2097.1312408853.14074.digitalmars-d-le...@puremagic.com... >I liked QLive before they forced 30 second commercials on server joins > for non-subscribers. :( > > It was cool being able to casually browse to other tabs, then going > back to qlive and

Re: NaCl stable ABI

2011-08-03 Thread Andrej Mitrovic
I liked QLive before they forced 30 second commercials on server joins for non-subscribers. :( It was cool being able to casually browse to other tabs, then going back to qlive and finding a game. UT for example had an integrated IRC client, but people preferred using mIRC and having a ut://123.1

Re: NaCl stable ABI

2011-08-03 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:j1cb3a$2qe7$1...@digitalmars.com... > > I mean this is the stupid motherfuck industry that's spent the last ten > years completely ignoring who they're *supposed* to be (***VIDEOGAME*** > developers) and instead running around as a bunch of goddamn > gra

Re: NaCl stable ABI

2011-08-03 Thread Nick Sabalausky
"Peter Alexander" wrote in message news:j1asck$81d$1...@digitalmars.com... > > The games industry has been crying out for something like NaCl for a long > time. It is exactly what we want: > > - Ability to launch games within browser without a plugin download > - Platform independent ABI > - No

Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Andrej Mitrovic
On 8/3/11, Andrej Mitrovic wrote: > if ((t - t_prev).usecs > (1_000_000.0 / FPS)) > { > t_prev = t; > DrawGLScene(); > } > > SwapBuffers(hDC); My mistake here, SwapBuffers belongs inside the if body, there's an unrelated keyboard bug that made me push it there but

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread Dmitry Olshansky
On 03.08.2011 22:26, simendsjo wrote: On 03.08.2011 19:15, Jonathan M Davis wrote: On 03.08.2011 18:18, Jonathan M Davis wrote: On Thursday 04 August 2011 00:27:12 Mike Parker wrote: On 8/3/2011 11:23 PM, simendsjo wrote: On 03.08.2011 15:49, bearophile wrote: simendsjo: void main() { asser

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread Steven Schveighoffer
On Wed, 03 Aug 2011 14:26:54 -0400, simendsjo wrote: Schveighoffer also states it is as designed. But it really doesn't behave as one (at least I) would expect. So in essence (as bearophile says), "is null" should not be used on arrays. I was bitten by a bug because of this, and used "" int

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread Jonathan M Davis
> On 03.08.2011 19:15, Jonathan M Davis wrote: > >> On 03.08.2011 18:18, Jonathan M Davis wrote: > >>> On Thursday 04 August 2011 00:27:12 Mike Parker wrote: > On 8/3/2011 11:23 PM, simendsjo wrote: > > On 03.08.2011 15:49, bearophile wrote: > >> simendsjo: > >>> void main() { > >>

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread Jonathan M Davis
> On Wed, 03 Aug 2011 06:35:08 -0400, simendsjo wrote: > > void main() { > > > > assert(is(typeof("") == typeof("".idup))); // both is > > > > immutable(char)[] > > > > assert("" !is null); > > assert("".idup !is null); // fails - s is null. Why? > > > > } > > An empty string manifest constan

Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Steven Schveighoffer
On Wed, 03 Aug 2011 13:42:34 -0400, Andrej Mitrovic wrote: That could be the reason. I'm testing on Windows. Windows only supports millisecond resolution. A valid solution to this is probably to have anything > 0 and < 1 ms sleep for at least 1ms. Or maybe it can round up to the next ms

Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Andrej Mitrovic
On 8/3/11, Jacob Carlborg wrote: > Why would you want to slow down framerate? Because the examples were written in the 90s and CPUs and graphic cards are so fast these days that the old code runs at an enormous framerate. Anyway, after a bit of googling I've found a solution: enum float FPS = 6

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread simendsjo
On 03.08.2011 19:15, Jonathan M Davis wrote: On 03.08.2011 18:18, Jonathan M Davis wrote: On Thursday 04 August 2011 00:27:12 Mike Parker wrote: On 8/3/2011 11:23 PM, simendsjo wrote: On 03.08.2011 15:49, bearophile wrote: simendsjo: void main() { assert(is(typeof("") == typeof("".idup))); /

Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Jacob Carlborg
On 2011-08-03 19:42, Andrej Mitrovic wrote: That could be the reason. I'm testing on Windows. I was using sleep() as a quick hack around slowing down the framerate of an OpenGL display. There are better way to do this but I didn't have time to find a proper solution yet. Why would you want to

Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Andrej Mitrovic
That could be the reason. I'm testing on Windows. I was using sleep() as a quick hack around slowing down the framerate of an OpenGL display. There are better way to do this but I didn't have time to find a proper solution yet.

Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Steven Schveighoffer
On Wed, 03 Aug 2011 13:14:50 -0400, Andrej Mitrovic wrote: Take a look at this: import std.stdio; import core.thread; void main() { foreach (x; 0 .. 1000) { Thread.sleep(dur!("usecs")(999)); writeln(x); } foreach (x; 0 .. 1000) { Thread.sleep(dur

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread Steven Schveighoffer
On Wed, 03 Aug 2011 06:35:08 -0400, simendsjo wrote: void main() { assert(is(typeof("") == typeof("".idup))); // both is immutable(char)[] assert("" !is null); assert("".idup !is null); // fails - s is null. Why? } An empty string manifest constant (i.e. string literal

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread Jonathan M Davis
> On 03.08.2011 18:18, Jonathan M Davis wrote: > > On Thursday 04 August 2011 00:27:12 Mike Parker wrote: > >> On 8/3/2011 11:23 PM, simendsjo wrote: > >>> On 03.08.2011 15:49, bearophile wrote: > simendsjo: > > void main() { > > assert(is(typeof("") == typeof("".idup))); // both is >

Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Andrej Mitrovic
s/sleep while/sleep value

Weird timing issue with Thread.sleep

2011-08-03 Thread Andrej Mitrovic
Take a look at this: import std.stdio; import core.thread; void main() { foreach (x; 0 .. 1000) { Thread.sleep(dur!("usecs")(999)); writeln(x); } foreach (x; 0 .. 1000) { Thread.sleep(dur!("usecs")(1000)); writeln(x); } } Compile and run i

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread simendsjo
On 03.08.2011 18:18, Jonathan M Davis wrote: On Thursday 04 August 2011 00:27:12 Mike Parker wrote: On 8/3/2011 11:23 PM, simendsjo wrote: On 03.08.2011 15:49, bearophile wrote: simendsjo: void main() { assert(is(typeof("") == typeof("".idup))); // both is immutable(char)[] assert("" !is nul

Re: Hexadecimal string to integer

2011-08-03 Thread Stijn Herreman
On 3/08/2011 2:32, Johann MacDonagh wrote: On 8/2/2011 8:17 PM, Stijn Herreman wrote: std.conv does not support conversion from a hexadecimal string to an integer. Is there a technical reason for this limitation? This is the best I could do, can it be improved still? int i = to!int(parse!float(

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread Jonathan M Davis
On Thursday 04 August 2011 00:27:12 Mike Parker wrote: > On 8/3/2011 11:23 PM, simendsjo wrote: > > On 03.08.2011 15:49, bearophile wrote: > >> simendsjo: > >>> void main() { > >>> assert(is(typeof("") == typeof("".idup))); // both is > >>> immutable(char)[] > >>> > >>> assert("" !is null); > >>>

Re: NaCl stable ABI

2011-08-03 Thread Adam Ruppe
Peter Alexander wrote: > If D were usable in NaCl that would be a huge selling point for the > language. Well, let's set aside my personal things and see how this might be done. Based on what I've read so far, it actually sounds easy enough, codegen wise. It might be possible to drop gdc into th

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread Mike Parker
On 8/3/2011 11:23 PM, simendsjo wrote: On 03.08.2011 15:49, bearophile wrote: simendsjo: void main() { assert(is(typeof("") == typeof("".idup))); // both is immutable(char)[] assert("" !is null); assert("".idup !is null); // fails - s is null. Why? } I think someone has even suggested to st

Re: GG bug? (OS X Lion, DMD 2.054)

2011-08-03 Thread David Nadlinger
On 8/3/11 4:07 PM, Magnus Lie Hetland wrote: I upgraded from OS X Snow Leopard to Lion recently (on a 32-bit iMac), and when I tried to run my D code afterward, I suddenly ran into all kinds of interesting problems (lots of failed assertions in my tests, and bus errors in my actual runs...). Th

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread simendsjo
On 03.08.2011 15:49, bearophile wrote: simendsjo: void main() { assert(is(typeof("") == typeof("".idup))); // both is immutable(char)[] assert("" !is null); assert("".idup !is null); // fails - s is null. Why? } I think someone has even suggested to statically forbid "

Re: GG bug? (OS X Lion, DMD 2.054)

2011-08-03 Thread Magnus Lie Hetland
Note that an explicit call to GC.collect isn't necessary. Whenever collection occurs, the collectors seems rather indiscriminate, collecting things it shouldn't, resulting in bus errors. When I disable the GC, my code runs just fine. (My production code, that is. There are still mysterious, pro

GG bug? (OS X Lion, DMD 2.054)

2011-08-03 Thread Magnus Lie Hetland
I upgraded from OS X Snow Leopard to Lion recently (on a 32-bit iMac), and when I tried to run my D code afterward, I suddenly ran into all kinds of interesting problems (lots of failed assertions in my tests, and bus errors in my actual runs...). Still cleaning stuff up, but I've isolated at l

Re: "" gives an empty string, while "".idup gives null

2011-08-03 Thread bearophile
simendsjo: > void main() { > assert(is(typeof("") == typeof("".idup))); // both is immutable(char)[] > > assert("" !is null); > assert("".idup !is null); // fails - s is null. Why? > } I think someone has even suggested to statically forbid "is null" on strings :-) Bye, bear

Re: Convert string to wchar.

2011-08-03 Thread Jacob Carlborg
On 2011-08-03 09:34, Pelle wrote: On Wed, 03 Aug 2011 08:29:09 +0200, Jacob Carlborg wrote: Yes, convert the first code point to a wchar and then throw if there's more the one character in the string. Not tested, and I might be wrong, but 'to!' should work between dchar and wchar, no? wchar

Re: Convert string to wchar.

2011-08-03 Thread Jacob Carlborg
On 2011-08-03 08:38, Jonathan M Davis wrote: On Wednesday 03 August 2011 08:29:09 Jacob Carlborg wrote: On 2011-08-02 19:51, Jonathan M Davis wrote: I tried to convert a string into a wchar, but that didn't compile because of this template constraint: https://github.com/D-Programming-Language/

"" gives an empty string, while "".idup gives null

2011-08-03 Thread simendsjo
void main() { assert(is(typeof("") == typeof("".idup))); // both is immutable(char)[] assert("" !is null); assert("".idup !is null); // fails - s is null. Why? }

Re: Immutable member functions and private members

2011-08-03 Thread simendsjo
On 03.08.2011 12:01, Jonathan M Davis wrote: On Wednesday 03 August 2011 11:44:27 simendsjo wrote: On 03.08.2011 10:52, Jonathan M Davis wrote: On Wednesday 03 August 2011 10:37:58 simendsjo wrote: I have a struct with a private member that is only ever accessed through a single property metho

Re: Immutable member functions and private members

2011-08-03 Thread Jonathan M Davis
On Wednesday 03 August 2011 12:00:18 simendsjo wrote: > On 03.08.2011 11:44, simendsjo wrote: > > On 03.08.2011 10:52, Jonathan M Davis wrote: > >> On Wednesday 03 August 2011 10:37:58 simendsjo wrote: > >>> I have a struct with a private member that is only ever accessed > >>> through a single pro

Re: Immutable member functions and private members

2011-08-03 Thread simendsjo
On 03.08.2011 11:44, simendsjo wrote: On 03.08.2011 10:52, Jonathan M Davis wrote: On Wednesday 03 August 2011 10:37:58 simendsjo wrote: I have a struct with a private member that is only ever accessed through a single property method - even from within the struct. As this property fills the va

Re: Immutable member functions and private members

2011-08-03 Thread Jonathan M Davis
On Wednesday 03 August 2011 11:44:27 simendsjo wrote: > On 03.08.2011 10:52, Jonathan M Davis wrote: > > On Wednesday 03 August 2011 10:37:58 simendsjo wrote: > >> I have a struct with a private member that is only ever accessed > >> through > >> a single property method - even from within the stru

Re: Immutable member functions and private members

2011-08-03 Thread simendsjo
On 03.08.2011 10:52, Jonathan M Davis wrote: On Wednesday 03 August 2011 10:37:58 simendsjo wrote: I have a struct with a private member that is only ever accessed through a single property method - even from within the struct. As this property fills the value on the first access, it cannot be i

Re: Immutable member functions and private members

2011-08-03 Thread Jonathan M Davis
On Wednesday 03 August 2011 10:37:58 simendsjo wrote: > I have a struct with a private member that is only ever accessed through > a single property method - even from within the struct. > As this property fills the value on the first access, it cannot be > immutable, and as such, none of the many

Immutable member functions and private members

2011-08-03 Thread simendsjo
I have a struct with a private member that is only ever accessed through a single property method - even from within the struct. As this property fills the value on the first access, it cannot be immutable, and as such, none of the many methods accessing this property can be immutable methods.

Re: Convert string to wchar.

2011-08-03 Thread Jonathan M Davis
On Wednesday 03 August 2011 01:02:02 Jonathan M Davis wrote: > On Wednesday 03 August 2011 09:34:53 Pelle wrote: > > On Wed, 03 Aug 2011 08:29:09 +0200, Jacob Carlborg wrote: > > > Yes, convert the first code point to a wchar and then throw if > > > there's > > > more the one character in the stri

Re: Convert string to wchar.

2011-08-03 Thread Jonathan M Davis
On Wednesday 03 August 2011 09:34:53 Pelle wrote: > On Wed, 03 Aug 2011 08:29:09 +0200, Jacob Carlborg wrote: > > Yes, convert the first code point to a wchar and then throw if there's > > more the one character in the string. > > Not tested, and I might be wrong, but 'to!' should work between dc

Re: Convert string to wchar.

2011-08-03 Thread Pelle
On Wed, 03 Aug 2011 08:29:09 +0200, Jacob Carlborg wrote: Yes, convert the first code point to a wchar and then throw if there's more the one character in the string. Not tested, and I might be wrong, but 'to!' should work between dchar and wchar, no? wchar to_wchar(string s) { auto

Re: NaCl stable ABI

2011-08-03 Thread Peter Alexander
On 2/08/11 2:24 AM, Adam Ruppe wrote: From what I can tell, it's Google's alternative to Flash; they want to make crappy games on it. Consider that the first thing they ported to it, again, just like their javascript nonsense, was Quake. (I think Google loves Javascript too much to let it go an