Re: Char[] confusing

2009-03-05 Thread Stewart Gordon
Qian Xu wrote: IMO, it does not make any sense. s[start..end] end - is neither the count of characters in the array slice, nor the end index of the slice. it is just the index after the real end character. It might help to think of the indexes in a slice as numbering the

Re: Timer in D.API?

2009-03-05 Thread Christopher Wright
Sam Hu wrote: Thank you both so much. In DFL there is a Timer class but I can not get it work: It compiled but just print 2 lines of message: Before timer ... After timer... I am asking Chris Miller on DFL forum regarding this issue. In DWT,there is a Runnable class I think it can gain the same

Re: statement is not reachable

2009-03-05 Thread Jarrett Billingsley
On Thu, Mar 5, 2009 at 10:45 AM, Qian Xu wrote: > Hi Jarrett, > > but I need an exception here. This is an unexpected case. I want no instance > to be create in this case. By the time the constructor runs, an instance has already been created. But if you throw an exception in the ctor, it's impo

Re: array and pointer

2009-03-05 Thread takeshi
Hello Daniel, Thank you. It works. > If that's the example, then it's out of date. It should be this: > > int* p; > int[3] s; > p = s.ptr;

Re: statement is not reachable

2009-03-05 Thread Ary Borenszweig
Qian Xu wrote: Jarrett Billingsley wrote: On Thu, Mar 5, 2009 at 3:17 AM, Qian Xu wrote: this(char[] s, int flag) { if (flag == 1) { this(1); return; } else if (flag == 2) { this("hello"); return; } throw new Exception("unhandled case"); this(0); // fake This line is unreachable. The 'thro

Re: statement is not reachable

2009-03-05 Thread Qian Xu
Jarrett Billingsley wrote: > On Thu, Mar 5, 2009 at 3:17 AM, Qian Xu > wrote: > >> this(char[] s, int flag) { >> if (flag == 1) >> { >> this(1); >> return; >> } >> else if (flag == 2) >> { >> this("hello"); >> return; >> } >> throw new Exception("unhandled case"); >> this(0); // fake > > This l

Re: array and pointer

2009-03-05 Thread Derek Parnell
On Thu, 5 Mar 2009 12:52:14 + (UTC), takeshi wrote: > Hello, I have just started learning D. > > I cannot compile the code in the documentation on array and pointer > either with dmd (D 2.0) and gdmd (D 1.0). > > Is some compile option or cast required? > > int* p; > int[3] s; > p = s; Try

Re: statement is not reachable

2009-03-05 Thread Jarrett Billingsley
On Thu, Mar 5, 2009 at 3:17 AM, Qian Xu wrote: >  this(char[] s, int flag) { >    if (flag == 1) >    { >      this(1); >      return; >    } >    else if (flag == 2) >    { >      this("hello"); >      return; >    } >    throw new Exception("unhandled case"); >    this(0); // fake This line is

Re: array and pointer

2009-03-05 Thread Daniel Keep
takeshi wrote: > Hello, I have just started learning D. > > I cannot compile the code in the documentation on array and pointer > either with dmd (D 2.0) and gdmd (D 1.0). > > Is some compile option or cast required? > > int* p; > int[3] s; > p = s; If that's the example, then it's out of dat

array and pointer

2009-03-05 Thread takeshi
Hello, I have just started learning D. I cannot compile the code in the documentation on array and pointer either with dmd (D 2.0) and gdmd (D 1.0). Is some compile option or cast required? int* p; int[3] s; p = s;

statement is not reachable

2009-03-05 Thread Qian Xu
Hi All, I have got a warning by compiling ("gdc file -Wall") the following code -- module unreachable; class Foo { this(int i) {} this(char[] s) {} this(char[] s, int flag) { if (flag == 1) { this(1); return; }