range properties that work in foreach

2010-03-06 Thread Michael Rynn
On the D2 online pages (http://www.digitalmars.com/d/2.0/statement.html#ForeachStatement)there is Foreach over Structs and Classes with Ranges My question is , is there a working example of foreach ( e ; range )? Iteration over struct and class objects can be done with ranges, which

Re: range properties that work in foreach

2010-03-06 Thread Lars T. Kyllingstad
Michael Rynn wrote: On the D2 online pages (http://www.digitalmars.com/d/2.0/statement.html#ForeachStatement)there is Foreach over Structs and Classes with Ranges My question is , is there a working example of foreach ( e ; range )? Iteration over struct and class objects can be done

Re: range properties that work in foreach

2010-03-06 Thread Lars T. Kyllingstad
Lars T. Kyllingstad wrote: Michael Rynn wrote: On the D2 online pages (http://www.digitalmars.com/d/2.0/statement.html#ForeachStatement)there is Foreach over Structs and Classes with Ranges My question is , is there a working example of foreach ( e ; range )? Iteration over struct and

interface problem

2010-03-06 Thread Trass3r
I got 2 classes which both (indirectly) inherit from a common base class and implement a certain interface I. Now I need to pass that interface to a function and need to call a function inherited from the base class inside. Naturally that function is not present in the interface and thus can't

Re: interface problem

2010-03-06 Thread bearophile
Trass3r: I got 2 classes which both (indirectly) inherit from a common base class and implement a certain interface I. When possible show an example. You can fill/fix the following code to create an example of your problem: interface IFoo { void foo(); } class Base { void foo() {} }

Re: Static attributes aren' immutable

2010-03-06 Thread bearophile
div0: Yeah, I *never* access static vars through an instance, I always use the class name. Somebody want to post in the main group? It seems there are few people that agree with you, but Walter has not answered about this yet, so you can ask him his opinion. I like to use a tidy language.

Re: interface problem

2010-03-06 Thread Jacob Carlborg
On 3/6/10 13:39, Trass3r wrote: I got 2 classes which both (indirectly) inherit from a common base class and implement a certain interface I. Now I need to pass that interface to a function and need to call a function inherited from the base class inside. Naturally that function is not

Re: D2: std.algorithm.find, but get part before what you were searching for

2010-03-06 Thread Nick Sabalausky
Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote in message news:hmnu5l$31j...@digitalmars.com... 3. It's sometimes unclear which symbols are members of a class/struct and which are module-level symbols. Tango's API documentation is better in this regard, since it has the symbol tree

Re: range properties that work in foreach

2010-03-06 Thread Jesse Phillips
Good range documentation comes from: http://digitalmars.com/d/2.0/phobos/std_range.html foreach only requires an Input Range.

Re: interface problem

2010-03-06 Thread Trass3r
Cast the instance to the base class and call the method? Surprisingly this does compile. What are the rules for casting between classes?

void initialization vs alignment holes

2010-03-06 Thread strtr
This is probably going a bit above my head, but the existence of alignment holes in the objects is accounted for, usually by setting them all to 0 upon initialization I suspect this isn't the case for void initialization; if my struct has some alignment hole I better not void initialize it if

Re: void initialization vs alignment holes

2010-03-06 Thread bearophile
strtr: I suspect this isn't the case for void initialization; if my struct has some alignment hole I better not void initialize it if ever I want to compare it with somthing. Is this correct? That has to be correct. Would you ever have an alignment hole if all the struct contains are

Re: void initialization vs alignment holes

2010-03-06 Thread BCS
Hello Strtr, Would you ever have an alignment hole if all the struct contains are basic types(excluding bool)? real, char[n], byte[n] and short[m] (for n%4 != 0 and m%2 != 0) might be an issue. -- ... IXOYE

Re: void initialization vs alignment holes

2010-03-06 Thread strtr
BCS Wrote: Hello Strtr, Would you ever have an alignment hole if all the struct contains are basic types(excluding bool)? real, char[n], byte[n] and short[m] (for n%4 != 0 and m%2 != 0) might be an issue. Sounds logical, thanks!

Re: void initialization vs alignment holes

2010-03-06 Thread BCS
Hello Strtr, BCS Wrote: Hello Strtr, Would you ever have an alignment hole if all the struct contains are basic types(excluding bool)? real, char[n], byte[n] and short[m] (for n%4 != 0 and m%2 != 0) might be an issue. Sounds logical, thanks! I don't actually *know* those will be a

Re: void initialization vs alignment holes

2010-03-06 Thread strtr
bearophile Wrote: strtr: I suspect this isn't the case for void initialization; if my struct has some alignment hole I better not void initialize it if ever I want to compare it with something. Is this correct? That has to be correct. Might this be worth an explicit mention on

Re: void initialization vs alignment holes

2010-03-06 Thread BCS
Hello Strtr, Suppose I'd still would like to use void optimizations, how do you clear the holes manually? IIRC zero filling a block is likely cheaper that zero filling holes in it. I'd avoid =void unless you know you will be copying structs into the space (that will copy the holes as