Re: Polymorphic ranges?

2011-05-01 Thread Andrej Mitrovic
s/they/the

Re: Polymorphic ranges?

2011-05-01 Thread Andrej Mitrovic
The reason I've posted them online is because they snippets are not that short. And it's much easier to read them from a syntax-highlighted website than from a plaintext newsgroup reader.

Re: Polymorphic ranges?

2011-05-01 Thread Ali Çehreli
On 05/01/2011 09:09 AM, Andrej Mitrovic wrote: Yeah it seems a common interface is what I should have used. I've tried it in numerous ways but I got the interface type wrong apparently. Thanks Dmitry. Here's a quick example: http://codepad.org/RhNiUHU2 To make it more convenient to others, I p

Re: Polymorphic ranges?

2011-05-01 Thread Ali Çehreli
On 05/01/2011 08:04 AM, Dmitry Olshansky wrote: On 01.05.2011 18:30, Andrej Mitrovic wrote: I'm not sure how to use those wrappers though. Maybe I'm just doing it wrong: http://codepad.org/eHIdhasc But it seems these wrappers have some problems, the docs say about the interfaces: Limitations:

Re: Polymorphic ranges?

2011-05-01 Thread Ali Çehreli
On 05/01/2011 07:30 AM, Andrej Mitrovic wrote: I'm not sure how to use those wrappers though. Maybe I'm just doing it wrong: http://codepad.org/eHIdhasc To make it more convenient to others, I paste Andrej Mitrovic's code: import std.stdio; import std.range; import core.thread; import std.ran

Re: Is int faster than byte/short?

2011-05-01 Thread Steven Wawryk
This is a good point. Further to that, keep in mind locality of reference, ie the performance impact of data getting pushed out of the caches. While using machine word size variables for a small number of variables that really need high performance can give a small speed-up, using them exte

Re: Polymorphic ranges?

2011-05-01 Thread Andrej Mitrovic
opSlice isn't supported either. Gah.., so much for this being useful. I'll have to roll my own. Now I know why Tango was developed.

traits and class protection

2011-05-01 Thread Adam D. Ruppe
Is there a way in today's D to exclude members marked private and protected from processing in the __traits(allMembers) family of functions? I thought if I at least put it in a separate module, trying to get a private member would fail to compile, but I tried it and it seems to work anyway... my p

Re: const/immutable violation?

2011-05-01 Thread Jason House
Ashish Myles Wrote: > foo2 = foo; // allowed immutable RHS ??? Allowing this is a bug. File it in bugzilla. Unfortunately, lazy objects "mess up" the expected const correctness of Object. Even if they are logically const, lazy objects can't always be passed as const.

Re: Polymorphic ranges?

2011-05-01 Thread Dmitry Olshansky
On 01.05.2011 21:40, Andrej Mitrovic wrote: Btw, * Limitations: * * These interfaces are not capable of forwarding $(D ref) access to elements. Why not? I can use auto ref to make e.g. an input range interface that can return ref elements: http://codepad.org/kmenIDk7 Why aren't the inte

Re: "not an lvalue"

2011-05-01 Thread Dmitry Olshansky
On 01.05.2011 19:31, Peter Alexander wrote: On 1/05/11 2:53 PM, Dmitry Olshansky wrote: Ehm.. Well, first things first: you shouldn't use classes for lightweight & plain data things like vectors. There are structs for that. In general, structs are value-like objects living on the stack while cla

Re: Polymorphic ranges?

2011-05-01 Thread Andrej Mitrovic
Btw, * Limitations: * * These interfaces are not capable of forwarding $(D ref) access to elements. Why not? I can use auto ref to make e.g. an input range interface that can return ref elements: http://codepad.org/kmenIDk7 Why aren't the interfaces defined like that in std.range?

Re: Polymorphic ranges?

2011-05-01 Thread Andrej Mitrovic
Actually that design of mine was bad because it creates a long chain of virtual calls since setStep just wraps the buffer object and creates a new object every time. Here's an alternate implementation: https://gist.github.com/950647

Re: private template members

2011-05-01 Thread Mike Wey
On 05/01/2011 03:15 PM, Dmitry Olshansky wrote: On 01.05.2011 16:38, hunt0r wrote: I was calling it from another module: in file Test.d: class Test { private: int x; void testNonTemplate() { } template test() { void test() {x= 100;} } public: int getX() {return x;} } In file main.d: import Test;

Re: Polymorphic ranges?

2011-05-01 Thread Andrej Mitrovic
Unfortunately as you can see I can't convert a Stride to a RandomAccessInfinite object, so I've had to use an InputRange interface (I can also use ForwardRange which is more derived). I'm not sure why I can't use it (maybe it's that bug again?), because Stride itself does offer random access.

Re: Polymorphic ranges?

2011-05-01 Thread Andrej Mitrovic
Yeah it seems a common interface is what I should have used. I've tried it in numerous ways but I got the interface type wrong apparently. Thanks Dmitry. Here's a quick example: http://codepad.org/RhNiUHU2 I hope those bugs get squashed so I can have more fun with these ranges. :)

Re: "not an lvalue"

2011-05-01 Thread Peter Alexander
On 1/05/11 2:53 PM, Dmitry Olshansky wrote: Ehm.. Well, first things first: you shouldn't use classes for lightweight & plain data things like vectors. There are structs for that. In general, structs are value-like objects living on the stack while classes are reference-like objects living on the

Re: Polymorphic ranges?

2011-05-01 Thread Dmitry Olshansky
On 01.05.2011 18:30, Andrej Mitrovic wrote: I'm not sure how to use those wrappers though. Maybe I'm just doing it wrong: http://codepad.org/eHIdhasc But it seems these wrappers have some problems, the docs say about the interfaces: Limitations: These interfaces are not capable of forwarding r

Re: "not an lvalue"

2011-05-01 Thread CrypticMetaphor
On 5/1/2011 3:53 PM, Dmitry Olshansky wrote: Ehm.. Well, first things first: you shouldn't use classes for lightweight & plain data things like vectors. There are structs for that. In general, structs are value-like objects living on the stack while classes are reference-like objects living on th

Re: Polymorphic ranges?

2011-05-01 Thread Andrej Mitrovic
I'm not sure how to use those wrappers though. Maybe I'm just doing it wrong: http://codepad.org/eHIdhasc But it seems these wrappers have some problems, the docs say about the interfaces: Limitations: These interfaces are not capable of forwarding ref access to elements. Infiniteness of the wra

Re: "not an lvalue"

2011-05-01 Thread CrypticMetaphor
Yes, you were right: Vector3 { // ... /// Binary operator for operator + and - public Vector3 opBinary(string op) (const ref Vector3 rhs) const if (op == "+" || op == "-") { mixin("return new Vector3(x" ~ op ~ "rhs.x, y" ~ op ~ "rhs.y, z" ~ op ~ "rhs.z);"); } // ... } I removed ref a

Re: "not an lvalue"

2011-05-01 Thread Dmitry Olshansky
On 01.05.2011 17:30, CrypticMetaphor wrote: Hi, I've been away from D for a while, but now I'm back and I'm stuck with an compile time error. I've got a Matrix33 class and a Vector3 class, but something is wrong with the way I return my Vector3 in my matrix class: If I do this I get an error

Re: "not an lvalue"

2011-05-01 Thread Peter Alexander
On 1/05/11 2:30 PM, CrypticMetaphor wrote: Hi, I've been away from D for a while, but now I'm back and I'm stuck with an compile time error. I've got a Matrix33 class and a Vector3 class, but something is wrong with the way I return my Vector3 in my matrix class: If I do this I get an error: M

"not an lvalue"

2011-05-01 Thread CrypticMetaphor
Hi, I've been away from D for a while, but now I'm back and I'm stuck with an compile time error. I've got a Matrix33 class and a Vector3 class, but something is wrong with the way I return my Vector3 in my matrix class: If I do this I get an error: Matrix33 mtest = new Matrix33(); mtest.Set

Re: private template members

2011-05-01 Thread Dmitry Olshansky
On 01.05.2011 16:38, hunt0r wrote: I was calling it from another module: in file Test.d: class Test { private: int x; void testNonTemplate() { } template test() { void test() {x= 100;} } public: int getX() {return x;} } In file main.d: import

Re: private template members

2011-05-01 Thread hunt0r
I was calling it from another module: in file Test.d: class Test { private: int x; void testNonTemplate() { } template test() { void test() {x= 100;} } public: int getX() {return x;} } In file main.d: import Test; Test t = new Test; t.test(); /*ok*/ t.tes

Re: private template members

2011-05-01 Thread Dmitry Olshansky
On 01.05.2011 13:37, hunt0r wrote: hi, It seems that template members of a class are always public. having a class like: class Test { private: int x; template test(T) { void test(T t) {x= 100;} } public: int getX() {return x;} } and calling: Test t = new

Re: Is int faster than byte/short?

2011-05-01 Thread Dmitry Olshansky
On 30.04.2011 19:34, Mariusz Gliwiński wrote: Hello, I'm trying to learn high-performance real-time programming. One of my wonderings are: Should i use int/uint for all standard arithmetic operations or int/short/byte (depends on actual case)? I believe this question has following subquestions

Re: Polymorphic ranges?

2011-05-01 Thread Dmitry Olshansky
On 01.05.2011 6:33, Andrej Mitrovic wrote: As an example I have a cyclic buffer (using std.range.Cycle) where I can set the lower and upper bounds of the buffer. I'd also like to enable a stepping mode, so I thought first about using std.range.Stride. The code: http://codepad.org/TR7NDWTC Thi

private template members

2011-05-01 Thread hunt0r
hi, It seems that template members of a class are always public. having a class like: class Test { private: int x; template test(T) { void test(T t) {x= 100;} } public: int getX() {return x;} } and calling: Test t = new Test; t.test(); prints 100 instead of sayin

Re: Linux: How to statically link against system libs?

2011-05-01 Thread Spacen Jasset
On 29/04/2011 21:02, Nick Sabalausky wrote: ... I'm having a rediculously hard time trying to find a CentOS 3 installation disc image (or any other version before 5.6). This is the closest I've been able to find: ... It seems that the older versions that are no longer supported have generall