Re: Multiple subtyping

2011-08-25 Thread Timon Gehr
On 08/26/2011 05:45 AM, Joel Christensen wrote: Hi, Has anyone had much experience with multiple subtyping. //Org: based on page 232 (6.13.1) in The D Programming Language book //#save(); without storeShape does not work import std.stdio; class Shape { void shape() { writeln( "Shape" ); } } c

Re: Reading by character and by line from stdin

2011-08-25 Thread Timon Gehr
On 08/26/2011 06:12 AM, Joel Christensen wrote: On 26-Aug-11 10:20 AM, Timon Gehr wrote: On 08/26/2011 12:19 AM, Timon Gehr wrote: On 08/25/2011 11:34 PM, bellinom wrote: whoops, this is better: auto arr=to!(int[])(split(strip!(readln(; Or, auto arr2=to!(int[])( readln.strip.split );

Re: Reading by character and by line from stdin

2011-08-25 Thread Joel Christensen
On 26-Aug-11 10:20 AM, Timon Gehr wrote: On 08/26/2011 12:19 AM, Timon Gehr wrote: On 08/25/2011 11:34 PM, bellinom wrote: whoops, this is better: auto arr=to!(int[])(split(strip!(readln(; Or, auto arr2=to!(int[])( readln.strip.split ); Got rid of the second ! too (does not work with i

Multiple subtyping

2011-08-25 Thread Joel Christensen
Hi, Has anyone had much experience with multiple subtyping. //Org: based on page 232 (6.13.1) in The D Programming Language book //#save(); without storeShape does not work import std.stdio; class Shape { void shape() { writeln( "Shape" ); } } class DataBase {

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Timon Gehr
On 08/26/2011 02:00 AM, Ali Çehreli wrote: On Thu, 25 Aug 2011 23:31:26 +0200, Timon Gehr wrote: for(init; condition; statement){} while(condition ){} That's a very interesting way of looking at the question. I bet that explains the other way around: there can't be a variable d

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Ali Çehreli
On Thu, 25 Aug 2011 23:31:26 +0200, Timon Gehr wrote: > for(init; condition; statement){} > while(condition ){} That's a very interesting way of looking at the question. I bet that explains the other way around: there can't be a variable definition in the 'for' loop's condition cl

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Timon Gehr
On 08/26/2011 12:38 AM, Steven Schveighoffer wrote: On Thu, 25 Aug 2011 17:31:26 -0400, Timon Gehr wrote: On 08/25/2011 10:51 PM, Steven Schveighoffer wrote: > On Thu, 25 Aug 2011 12:21:19 -0400, Timon Gehr wrote: > > >> >> I usually replace code like this: >> >> x++; >> if(x < 100) >> { >> /

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Steven Schveighoffer
On Thu, 25 Aug 2011 17:31:26 -0400, Timon Gehr wrote: On 08/25/2011 10:51 PM, Steven Schveighoffer wrote: > On Thu, 25 Aug 2011 12:21:19 -0400, Timon Gehr wrote: > > >> >> I usually replace code like this: >> >> x++; >> if(x < 100) >> { >> // use x >> } >> >> with this: >> >>

Re: Reading by character and by line from stdin

2011-08-25 Thread Timon Gehr
On 08/26/2011 12:19 AM, Timon Gehr wrote: On 08/25/2011 11:34 PM, bellinom wrote: > Thanks for that, I didn't realize they were that far out of date. I use the latest > version of the compiler on my home PC, so I'd like to know the most current ways > of reading from stdin. > > Thanks Curre

Re: Reading by character and by line from stdin

2011-08-25 Thread Timon Gehr
On 08/25/2011 11:34 PM, bellinom wrote: > Thanks for that, I didn't realize they were that far out of date. I use the latest > version of the compiler on my home PC, so I'd like to know the most current ways > of reading from stdin. > > Thanks Currently what you get is readf and readln with st

Re: Reading by character and by line from stdin

2011-08-25 Thread Jonathan M Davis
On Thursday, August 25, 2011 14:34 bellinom wrote: > Thanks for that, I didn't realize they were that far out of date. I use the > latest version of the compiler on my home PC, so I'd like to know the most > current ways of reading from stdin. That's probably not something that has changed, but ma

Re: Reading by character and by line from stdin

2011-08-25 Thread Trass3r
A nifty way of reading by byte is Of course I mean by character.

Re: Reading by character and by line from stdin

2011-08-25 Thread Trass3r
I'd like to know how to read from stdin one character at a time, read with whitespace as a delimiter, and read line by line. A nifty way of reading by byte is the undocumented (only the writer is documented): import std.stdio; void main() { foreach(c; LockingTextReader(stdin)) .

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Timon Gehr
On 08/25/2011 10:51 PM, Steven Schveighoffer wrote: > On Thu, 25 Aug 2011 12:21:19 -0400, Timon Gehr wrote: > > >> >> I usually replace code like this: >> >> x++; >> if(x < 100) >> { >> // use x >> } >> >> with this: >> >> if(++x < 100) { >> // use x >> } >> >> so the logical mapping to while wou

Re: Reading by character and by line from stdin

2011-08-25 Thread bellinom
Thanks for that, I didn't realize they were that far out of date. I use the latest version of the compiler on my home PC, so I'd like to know the most current ways of reading from stdin. Thanks

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Steven Schveighoffer
On Thu, 25 Aug 2011 12:21:19 -0400, Timon Gehr wrote: I usually replace code like this: x++; if(x < 100) { // use x } with this: if(++x < 100) { // use x } so the logical mapping to while would map this: x++; while(x < 100) { // use x. } to this: while(++x < 100) { //

Re: Importing D libraries

2011-08-25 Thread Dainius (GreatEmerald)
Yeap, it's definitely a bug, and the temp file is in fact the library that I need. Anyway I'm trying to compile it on Windows now. However, there are two problems. First of all, the Windows Command Prompt does not expand wildcards, and DMD does not take it as an argument. Thus importing LuaD as a

Re: Regarding nothrow and @safe

2011-08-25 Thread Jonathan M Davis
On Thursday, August 25, 2011 11:38 Nick Sabalausky wrote: > "Jacob Carlborg" wrote in message > news:j2qn7n$1db7$1...@digitalmars.com... > > > On 2011-08-21 02:26, Jonathan M Davis wrote: > >> The short answer: You don't. It's an incredibly bad idea. > >> > >> The long answer: You catch Error -

Re: Regarding nothrow and @safe

2011-08-25 Thread Nick Sabalausky
"Jacob Carlborg" wrote in message news:j2qn7n$1db7$1...@digitalmars.com... > On 2011-08-21 02:26, Jonathan M Davis wrote: >> >> The short answer: You don't. It's an incredibly bad idea. >> >> The long answer: You catch Error - or OutOfMemoryError if you want that >> specific one. So, you could tr

Re: Reading by character and by line from stdin

2011-08-25 Thread Jonathan M Davis
On Thursday, August 25, 2011 10:49 bellinom wrote: > Hello, > > I'm in the process of learning D, and I have some questions about reading > from stdin. I've checked out the documentation but it's really not helping > too much. I'd like to know how to read from stdin one character at a time, > read

Reading by character and by line from stdin

2011-08-25 Thread bellinom
Hello, I'm in the process of learning D, and I have some questions about reading from stdin. I've checked out the documentation but it's really not helping too much. I'd like to know how to read from stdin one character at a time, read with whitespace as a delimiter, and read line by line. Essenti

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Timon Gehr
On 08/25/2011 05:31 PM, Steven Schveighoffer wrote: > On Thu, 25 Aug 2011 11:15:44 -0400, Jonathan M Davis > wrote: > >> On Thursday, August 25, 2011 07:11:31 Steven Schveighoffer wrote: >>> > On 08/25/2011 12:47 AM, Mafi wrote: > >>> >> I'm not really sure if it's good for 'while'. >>> >> I'm un

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Jonathan M Davis
On Thursday, August 25, 2011 11:31:56 Steven Schveighoffer wrote: > On Thu, 25 Aug 2011 11:15:44 -0400, Jonathan M Davis > > wrote: > > On Thursday, August 25, 2011 07:11:31 Steven Schveighoffer wrote: > >> > On 08/25/2011 12:47 AM, Mafi wrote: > >> >> I'm not really sure if it's good for 'while'

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Steven Schveighoffer
On Thu, 25 Aug 2011 11:15:44 -0400, Jonathan M Davis wrote: On Thursday, August 25, 2011 07:11:31 Steven Schveighoffer wrote: > On 08/25/2011 12:47 AM, Mafi wrote: >> I'm not really sure if it's good for 'while'. >> I'm unsure because there are two somewhat natural semantics for such a

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Jonathan M Davis
On Thursday, August 25, 2011 07:11:31 Steven Schveighoffer wrote: > On Wed, 24 Aug 2011 19:01:31 -0400, Timon Gehr wrote: > > On 08/25/2011 12:47 AM, Mafi wrote: > >> Am 24.08.2011 21:04, schrieb Timon Gehr: > >>> On 08/24/2011 08:04 PM, Andrej Mitrovic wrote: > Here's some code that iterates

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Timon Gehr
On 08/25/2011 01:11 PM, Steven Schveighoffer wrote: On Wed, 24 Aug 2011 19:01:31 -0400, Timon Gehr wrote: On 08/25/2011 12:47 AM, Mafi wrote: Am 24.08.2011 21:04, schrieb Timon Gehr: On 08/24/2011 08:04 PM, Andrej Mitrovic wrote: Here's some code that iterates through "parents" of some clas

Re: Create a foreach-able struct? Multi-dimensional even?

2011-08-25 Thread Heywood Floyd
Christophe Wrote: > > Still, is the multi-dimensional part possible? > > Sure, you have to make an opApply that takes several parameters in its > delegate. > An exemple: > > struct TwoDArray(int nx, int ny) > { > int[nx][ny] data; > > int opApply(int delegate(ref int i, ref int j, ref int

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Steven Schveighoffer
On Wed, 24 Aug 2011 19:01:31 -0400, Timon Gehr wrote: On 08/25/2011 12:47 AM, Mafi wrote: Am 24.08.2011 21:04, schrieb Timon Gehr: On 08/24/2011 08:04 PM, Andrej Mitrovic wrote: Here's some code that iterates through "parents" of some class object until it finds an object with no parent (whe

Re: Create a foreach-able struct? Multi-dimensional even?

2011-08-25 Thread Christophe
> Still, is the multi-dimensional part possible? Sure, you have to make an opApply that takes several parameters in its delegate. An exemple: struct TwoDArray(int nx, int ny) { int[nx][ny] data; int opApply(int delegate(ref int i, ref int j, ref int cell) { foreach (i; 0..nx)

Re: Create a foreach-able struct? Multi-dimensional even?

2011-08-25 Thread Heywood Floyd
Heywood Floyd Wrote: > > Hello! > > 1) How do I create a struct that I can foreach over? > > I get the impression opApply has something do to with this, but I can't find > any documentation on it? (And I'm abroad without my TDPL.) > > > 2) Also, is it possible to do something like this? >

Create a foreach-able struct? Multi-dimensional even?

2011-08-25 Thread Heywood Floyd
Hello! 1) How do I create a struct that I can foreach over? I get the impression opApply has something do to with this, but I can't find any documentation on it? (And I'm abroad without my TDPL.) 2) Also, is it possible to do something like this? MyData!(100,100,100) data; foreach(x, y,