Re: loop through specific class members

2009-01-25 Thread BCS
Hello Sergey, foreach() is a runtime construct. It may be *interpreted* at compile-time, but it's interpreted as if it were run time nevertheless. It dynamically changes the value of 'member' variable. OTOH a foreach on a tuple is a compile time construct, but it is a distinct construct from

Re: loop through specific class members

2009-01-25 Thread Sergey Gromov
Wed, 21 Jan 2009 12:48:07 +0100, Trass3r wrote: > Christopher Wright schrieb: >> On the other hand, you can get the non-final, non-private methods of a >> class with something like: >> foreach (member; __traits (allMembers, Class)) >> { >> foreach (overload; __traits (getVirtualFunctions, Cla

Re: Is there a way to remove the requirement for parenthesis?

2009-01-25 Thread Sergey Gromov
Wed, 21 Jan 2009 09:24:01 -0800, Charles Hixson wrote: > In this test I'm trying to emulate how I want a typedef to act, but I > run into a problem: > > import std.stdio; > > struct BlockNum > { uint value; > > uint opCast() { return value; } > void opAssign (uint va

Re: how to use dll

2009-01-25 Thread Sergey Gromov
Wed, 21 Jan 2009 23:19:48 -0500, reimi gibbons wrote: > I'm currently developing a software with D and Tango. I don't have > much knowledge on DLL, but i do know when linking to static lib you > need a .h header file, but do i need .h for linking with DLL as well? > > > also can anybody please p

Re: Class and Interface Fun

2009-01-25 Thread John Reimer
Hello tim, On Mon, 26 Jan 2009 04:58:57 +1300, John Reimer wrote: Hello tim, On Mon, 26 Jan 2009 01:14:10 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 15:06:23 +0300, Tim M wrote: On Mon, 26 Jan 2009 00:48:21 +1300, Tim M wrote: On Mon, 26 Jan 2009 00:18:28

Re: Class and Interface Fun

2009-01-25 Thread Tim M
On Mon, 26 Jan 2009 04:58:57 +1300, John Reimer wrote: Hello tim, On Mon, 26 Jan 2009 01:14:10 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 15:06:23 +0300, Tim M wrote: On Mon, 26 Jan 2009 00:48:21 +1300, Tim M wrote: On Mon, 26 Jan 2009 00:18:28 +1300, Denis

Re: Class and Interface Fun

2009-01-25 Thread Christopher Wright
Denis Koroskin wrote: On Sun, 25 Jan 2009 08:38:18 +0300, Tim M wrote: class B : A,I { void foo() { A.foo(); } } void main() { } It is too verbose and makes twice an overhead. I'd like to avoid this solution. Any reasonable compiler would inline the call to A.foo. In fact, I belie

Re: Class and Interface Fun

2009-01-25 Thread John Reimer
Hello Daniel, [snip] B inherits all the functions from A implicitly. You stil may override any of the I interface functions if need be: class B : A, I { override void foo() { ... } // int bar() is inherited from A } Having B explicitly override all the base class virtual functions and forward

Re: Class and Interface Fun

2009-01-25 Thread John Reimer
Hello tim, It not a bug though. It's all here http://www.digitalmars.com/d/1.0/interface.html and it works like it says. Is there a problem? The only thing that might be close to a bug, I think, is the inability of the "alias" to satisfy the interface contract reimplementation. -JJR

Re: Class and Interface Fun

2009-01-25 Thread John Reimer
Hello tim, On Mon, 26 Jan 2009 01:14:10 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 15:06:23 +0300, Tim M wrote: On Mon, 26 Jan 2009 00:48:21 +1300, Tim M wrote: On Mon, 26 Jan 2009 00:18:28 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009

Re: Class and Interface Fun

2009-01-25 Thread John Reimer
Hello Daniel, [snip] B inherits all the functions from A implicitly. You stil may override any of the I interface functions if need be: class B : A, I { override void foo() { ... } // int bar() is inherited from A } Having B explicitly override all the base class virtual functions and forward

Re: C++ operator new

2009-01-25 Thread BLS
Daniel Keep wrote: This might also be of interest, as it has an example of overriding allocation/deallocation to use malloc: http://digitalmars.com/d/1.0/memory.html#newdelete Thanks! It seems that using freelists is preferable. Are there any drawbacks ? F.I. How to implement a class using fre

Re: Class and Interface Fun

2009-01-25 Thread Tim M
It not a bug though. It's all here http://www.digitalmars.com/d/1.0/interface.html and it works like it says. Is there a problem?

Re: Class and Interface Fun

2009-01-25 Thread Daniel Keep
[snip] B inherits all the functions from A implicitly. You stil may override any of the I interface functions if need be: class B : A, I { override void foo() { ... } // int bar() is inherited from A } Having B explicitly overr

Re: C++ operator new

2009-01-25 Thread Daniel Keep
This might also be of interest, as it has an example of overriding allocation/deallocation to use malloc: http://digitalmars.com/d/1.0/memory.html#newdelete

Re: Class and Interface Fun

2009-01-25 Thread Denis Koroskin
On Sun, 25 Jan 2009 17:06:50 +0300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 15:20:19 +0300, Tim M wrote: On Mon, 26 Jan 2009 01:14:10 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 15:06:23 +0300, Tim M wrote: On Mon, 26 Jan 2009 00:48:21 +13

Re: C++ operator new

2009-01-25 Thread Daniel Keep
BLS wrote: > Hi, > > I wonder if this is doable in D ? > > class Cpp > { > public: > void* operator new(size_t n); > void* operator new(size_t n, void* p) > { return p; } > > } > > Just guessing that operator new means this in D > class D > { > new(uint n); >

Re: Class and Interface Fun

2009-01-25 Thread Denis Koroskin
On Sun, 25 Jan 2009 15:20:19 +0300, Tim M wrote: On Mon, 26 Jan 2009 01:14:10 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 15:06:23 +0300, Tim M wrote: On Mon, 26 Jan 2009 00:48:21 +1300, Tim M wrote: On Mon, 26 Jan 2009 00:18:28 +1300, Denis Koroskin <2kor...

C++ operator new

2009-01-25 Thread BLS
Hi, I wonder if this is doable in D ? class Cpp { public: void* operator new(size_t n); void* operator new(size_t n, void* p) { return p; } } Just guessing that operator new means this in D class D { new(uint n); new(uint

Re: Class and Interface Fun

2009-01-25 Thread Tim M
On Mon, 26 Jan 2009 01:14:10 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 15:06:23 +0300, Tim M wrote: On Mon, 26 Jan 2009 00:48:21 +1300, Tim M wrote: On Mon, 26 Jan 2009 00:18:28 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 08:38:18 +

Re: Class and Interface Fun

2009-01-25 Thread Denis Koroskin
On Sun, 25 Jan 2009 15:06:23 +0300, Tim M wrote: On Mon, 26 Jan 2009 00:48:21 +1300, Tim M wrote: On Mon, 26 Jan 2009 00:18:28 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 08:38:18 +0300, Tim M wrote: On Sun, 25 Jan 2009 17:56:03 +1300, John Reimer wrote:

Re: Class and Interface Fun

2009-01-25 Thread Tim M
On Mon, 26 Jan 2009 00:48:21 +1300, Tim M wrote: On Mon, 26 Jan 2009 00:18:28 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 08:38:18 +0300, Tim M wrote: On Sun, 25 Jan 2009 17:56:03 +1300, John Reimer wrote: Hello tim, On Sun, 25 Jan 2009 16:43:55 +1300, Joh

Re: Class and Interface Fun

2009-01-25 Thread Tim M
On Mon, 26 Jan 2009 00:18:28 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 25 Jan 2009 08:38:18 +0300, Tim M wrote: On Sun, 25 Jan 2009 17:56:03 +1300, John Reimer wrote: Hello tim, On Sun, 25 Jan 2009 16:43:55 +1300, John Reimer wrote: With this code: ---

Re: Class and Interface Fun

2009-01-25 Thread Denis Koroskin
On Sun, 25 Jan 2009 08:38:18 +0300, Tim M wrote: On Sun, 25 Jan 2009 17:56:03 +1300, John Reimer wrote: Hello tim, On Sun, 25 Jan 2009 16:43:55 +1300, John Reimer wrote: With this code: module test5; interface I { void foo(); } class A : I { void f