Re: Facing problems with Class Properties

2010-12-10 Thread spir
On Sat, 11 Dec 2010 06:11:43 +0530 d coder wrote: > > if(false) { > >    for (size_t j = 0; j < f.length...) > >    ... > > } > > > > Semantically this code is wrong as you can't take the length of f which is > > class Bar. The static if forces the compiler to not generate this code as > > it i

Re: D2 byChunk

2010-12-10 Thread Christopher Nicholson-Sauls
On 12/10/10 22:36, Matthias Walter wrote: > On 12/10/2010 09:57 PM, Matthias Walter wrote: >> Hi all, >> >> I currently work on a parser for some file format. I wanted to use the >> std.stdio.ByChunk Range to read from a file and extract tokens from the >> chunks. Obviously it can happen that the c

Re: D2 byChunk

2010-12-10 Thread Matthias Walter
On 12/10/2010 09:57 PM, Matthias Walter wrote: > Hi all, > > I currently work on a parser for some file format. I wanted to use the > std.stdio.ByChunk Range to read from a file and extract tokens from the > chunks. Obviously it can happen that the current chunk ends before a > token can be extract

Re: Facing problems with Class Properties

2010-12-10 Thread Jesse Phillips
d coder Wrote: > > Ah.. Now I think I understand. > > > > This new code I have written will all be run at compile time. So in > > this case, the foreach statement inside the constructor would be > > reduced to a bunch of writeln statements at compile time and those > > writeln would be executed at

D2 byChunk

2010-12-10 Thread Matthias Walter
Hi all, I currently work on a parser for some file format. I wanted to use the std.stdio.ByChunk Range to read from a file and extract tokens from the chunks. Obviously it can happen that the current chunk ends before a token can be extracted, in which case I can ask for the next chunk from the Ra

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> Ah.. Now I think I understand. > > This new code I have written will all be run at compile time. So in > this case, the foreach statement inside the constructor would be > reduced to a bunch of writeln statements at compile time and those > writeln would be executed at the run time. This will not

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> Another thing, is(T : U) simply means T is implicitly castable to U.  Due to > a compiler bug, Bar[] is implicitly castable to BaseClass[]. > Steve I realize that I am using this compiler bug as a feature. It would be kind of you to suggest me a code that would not exploit this bug. I was think

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> What you are saying makes sense to me. The problem is that the > following code works perfectly. I have just commented out some part > and replaced it with some debug statements. Ah.. Now I think I understand. This new code I have written will all be run at compile time. So in this case, the fo

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> Is there a reason you can't directly reference the members?  After all, you > are writing the class. > Thanks Steve for your inputs. Actually this is part of a bigger code that I am trying to create. Though I am pretty new to D. What I have posted is a reduced code that illustrated the issue I

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> if(false) { >    for (size_t j = 0; j < f.length...) >    ... > } > > Semantically this code is wrong as you can't take the length of f which is > class Bar. The static if forces the compiler to not generate this code as it > is known to be false. > Thanks Jesse What you are saying makes sens

Re: Ddoc doesn't support documentation for mixined code?

2010-12-10 Thread Don
Alex Moroz wrote: Hi, As of present Ddoc doesn't seem to process documenatation for code that is inserted with mixins. Bug 2440?

Ddoc doesn't support documentation for mixined code?

2010-12-10 Thread Alex Moroz
Hi, As of present Ddoc doesn't seem to process documenatation for code that is inserted with mixins. For example: /** *Declares a protected field of type T, with default setter and getter for it. */ template Property(T,string name,string setterExtra="") { enum string Property="void "~name

Re: Facing problems with Class Properties

2010-12-10 Thread Steven Schveighoffer
On Fri, 10 Dec 2010 15:08:34 -0500, Jesse Phillips wrote: Jesse Phillips Wrote: typeof() and is() are compile time constructs. Change your if statements to static if. Just realized what the issue is. You are creating code as foreach becomes a static foreach when iterating a tupleof. (

Re: Facing problems with Class Properties

2010-12-10 Thread Jesse Phillips
Jesse Phillips Wrote: > typeof() and is() are compile time constructs. Change your if statements to > static if. Just realized what the issue is. You are creating code as foreach becomes a static foreach when iterating a tupleof. (Yes steven it does work) This you are building code which looks

Re: Facing problems with Class Properties

2010-12-10 Thread Jesse Phillips
d coder Wrote: > The issue is that when I try to compile the program, I get the error > bug.d(10): Error: no property 'length' for type 'test.Bar' > > I am explicitly checking the field type, and I am making sure that the field > is an array type, before looking for its length. So I am not sure w

Re: Facing problems with Class Properties

2010-12-10 Thread Steven Schveighoffer
On Fri, 10 Dec 2010 11:35:50 -0500, d coder wrote: Greetings All I am trying to compile the following D2 code. The code giving compilation issues is the "this()" function of the class Foo. The constructor basically tries to initialize all the data members of the class, of type BaseClass an

Facing problems with Class Properties

2010-12-10 Thread d coder
Greetings All I am trying to compile the following D2 code. The code giving compilation issues is the "this()" function of the class Foo. The constructor basically tries to initialize all the data members of the class, of type BaseClass and of type BaseClass array. I am using class property tuple

Re: first shot for a combinator library for d

2010-12-10 Thread Ellery Newcomer
Nice. Maybe add support for predicated alternatives? If you *really* want to make it more convenient, you could make a string mixin front for it, so that one could do something like mixin(maek_parser(" start -> s1 s2; s1 -> (`ab`|`cd`) `ef`; s2 -> (`1`|`2`|`3`); ")); I don't recommen

Re: String to enum

2010-12-10 Thread Jesse Phillips
useo Wrote: > Hi, > > does anyone know how I can cast a string to an enum which also > contains strings? For example: > > enum MyENUM : string { > > x = "123" > y = "456" > z = "789" > > } > > ... > > string myString = X; > to!(MyENUM)(myString); // Error: cannot implicitly convert > expres

first shot for a combinator library for d

2010-12-10 Thread Christian Köstlin
Hi, I try to learn D and as a testproject I wanted to implement combinator parsing for D. That's what I currently have: https://gist.github.com/736456#file_parser.d It is a simple combinator library including simple matchers, alternatives, sequences, optional, transformations of the results

String to enum

2010-12-10 Thread useo
Hi, does anyone know how I can cast a string to an enum which also contains strings? For example: enum MyENUM : string { x = "123" y = "456" z = "789" } ... string myString = X; to!(MyENUM)(myString); // Error: cannot implicitly convert expression (_adDupT((& D12TypeInfo_Aya6__initZ),s)) of

Comparing template alias parameters

2010-12-10 Thread Simen kjaeraas
Given an index structure like this: struct Index( alias arr ) if ( is( typeof( arr ) t : U[], U ) ) { private size_t idx; @property pure nothrow size_t get( ) const { return idx; } alias get this; invariant( ) { assert( idx < arr.length ); } this( siz