Re: TDPL's use of readf

2010-06-23 Thread Jonathan M Davis
Jeff Merrick wrote: > On page 22 of TDPL, we have the following code: > > import std.contracts, std.stdio; > void main(string[] args) { > // ... > for (double x; readf(" %s ", &x) == 1; ) { > // ... > } > // ... > } > > Using DMD v2.047, I get the following error on the readf call: >

TDPL's use of readf

2010-06-23 Thread Jeff Merrick
On page 22 of TDPL, we have the following code: import std.contracts, std.stdio; void main(string[] args) { // ... for (double x; readf(" %s ", &x) == 1; ) { // ... } // ... } Using DMD v2.047, I get the following error on the readf call: Error: undefined identifier readf, did you

Re: Best way to make Until! into string

2010-06-23 Thread Jonathan M Davis
Jonathan M Davis wrote: > div0 wrote: > >>> > [... snip of UTF-8 stuff ...] >> > > The UTF char stuff is all painfully complicated, and I _think_ that I more > or less understand it, but I suspect that I don't understand it all that > well. It would be nice if the there were a page in the docs s

Re: Why assert is in the language?

2010-06-23 Thread Jonathan M Davis
Tomek Sowiński wrote: > There's a better way: > > void assert_(string file = __FILE__, uint line = __LINE__)(bool pred, lazy > string msg = null) { > version(unittest) > if (!pred) > throw new AssertError(msg, file, line); > } > > If unittesting is off, it is inlined a

Multiple Alias this declarations?

2010-06-23 Thread JRM
On page 231, TDPL states that a class can introduce any number of alias this declarations. http://www.digitalmars.com/d/2.0/class.html#AliasThis states that there is only one allowed per class. A quick test shows that dmd agrees with the latter. Which one is right?

Re: Best way to make Until! into string

2010-06-23 Thread bearophile
div0: > and now with 2.047 I've been > bitten by the removal of struct initialisers. What do you mean? Bye, bearophile

Re: Tuple to tuple conversion

2010-06-23 Thread Ali Çehreli
Simen kjaeraas wrote: > "dmd a b -unittest" works. "dmd b a -unittest" does not. This may explain a problem that I hit recently. I had had all of a program's code in a single file. Then I started pulling classes to their respective source files one by one. As I did that, of course I compiled

Re: Why assert is in the language?

2010-06-23 Thread Tomek Sowiński
Dnia 23-06-2010 o 07:05:42 dennis luehring napisał(a): Am 22.06.2010 23:07, schrieb Tomek Sowiñski: Yes, why? It could be implemented in object.d in a similar fashion as std.contracts.enforce. Does it do anything special that a library function couldn't? Tomek what about static assert?

Re: Why assert is in the language?

2010-06-23 Thread Tomek Sowiński
Dnia 22-06-2010 o 23:55:29 Michal Minich napisał(a): On Tue, 22 Jun 2010 17:30:23 -0400, Steven Schveighoffer wrote: On Tue, 22 Jun 2010 17:07:02 -0400, Tomek Sowiński wrote: Yes, why? It could be implemented in object.d in a similar fashion as std.contracts.enforce. Does it do anything

linker error with timeval static-array

2010-06-23 Thread Chick Corea
Using v2.0.47, I get a linker error during compilation w/ the following code. import time = core.sys.posix.sys.time; int main( string[] argv ) { time.timeval x[4];// < the static array of timevals is the problem retu

Re: Best way to make Until! into string

2010-06-23 Thread div0
On 22/06/2010 23:05, Jonathan M Davis wrote: Oh my, you caveman! ;) I'd have to go look at all of the changelogs to even have a clue of what's been changed since then. Oh well, I guess that it means that you don't have to worry about stuff changing on you each upgrade by sticking to the same vers

Re: Cannot initialize associative array.

2010-06-23 Thread Rory McGuire
On Wed, 23 Jun 2010 00:30:40 +0200, Ali Çehreli wrote: dcoder wrote: > So, I moved the initialization to inside the main function, and now it works. > Great. I think we need to put this question in the FAQ. For future reference, if it really needs to be global: uint[string] mywords; s

Re: Forking problems on OS X 2.047

2010-06-23 Thread soul8o8
I get the same error. Fix: The following code works allright on MacOS X 10.6.4 / DMD v2.047: module fork; import core.sys.posix.unistd, core.thread,// added std.stdio; void main() { auto pid = fork(); if( pid> 0 ) { thread_attachThis();// adde

Re: Forking problems on OS X 2.047

2010-06-23 Thread soul8o8
Correction: Of course, you shouldn't call thread_attachThis() for the parent thread. It's already been attached since the D runtime created it. (In fact, the documentation says: "If [thread_attachThis()] is called for a thread which is already registered, the result is undefined." My bad.) B

Re: Cannot initialize associative array.

2010-06-23 Thread Bernard Helyer
On Wed, 23 Jun 2010 00:41:45 -0700, Ali Çehreli wrote: > Ali Çehreli wrote: >> dcoder wrote: >> >> > So, I moved the initialization to inside the main function, and now >> it works. >> > Great. I think we need to put this question in the FAQ. >> >> For future reference, if it really needs to

Re: Cannot initialize associative array.

2010-06-23 Thread bearophile
Ali Çehreli: > Could someone please verify whether the above is really necessary? An initialization inside some runtime function/initializator is necessary unless the AA is an enum. > Is it > actually a dmd bug that we need to use 'static this()' to initialize an > associative array? Accord

Re: Cannot initialize associative array.

2010-06-23 Thread Pelle
On 06/23/2010 09:41 AM, Ali Çehreli wrote: Ali Çehreli wrote: dcoder wrote: > So, I moved the initialization to inside the main function, and now it works. > Great. I think we need to put this question in the FAQ. For future reference, if it really needs to be global: uint[string] mywords; s

Re: Cannot initialize associative array.

2010-06-23 Thread Ali Çehreli
Ali Çehreli wrote: dcoder wrote: > So, I moved the initialization to inside the main function, and now it works. > Great. I think we need to put this question in the FAQ. For future reference, if it really needs to be global: uint[string] mywords; static this() { mywords = [ "Hello"

Re: Why assert is in the language?

2010-06-23 Thread Lutger
Ellery Newcomer wrote: > On 06/22/2010 05:36 PM, Ali Çehreli wrote: >> Jonathan M Davis wrote: >> > Steven Schveighoffer wrote: >> >> >> all calls to assert are removed by the compiler in release mode. I >> don't >> >> think there's a way to implement that via a library (it would be nice >> >>