Re: How to foreach over a DList?

2014-04-01 Thread monarch_dodra
On Tuesday, 1 April 2014 at 04:43:44 UTC, H. S. Teoh wrote: On Mon, Mar 31, 2014 at 09:55:01PM +, monarch_dodra wrote: On Monday, 31 March 2014 at 21:41:16 UTC, H. S. Teoh wrote: Argh, why is opSlice non-const? :-( Please file a bug. If opSlice was const, then you'd get a const slice,

How to dynamically call class virtual method dynamically

2014-04-01 Thread Frustrated
Basically in programming to interfaces I need to decide to call a virtual method of an object if it exists else call a final method in the interface: interface A { static final void foo() { ... } } class B : A { void bar() { ... } // optional } class C : B { void bar() { ...

Re: How to dynamically call class virtual method dynamically

2014-04-01 Thread John Colvin
On Tuesday, 1 April 2014 at 07:31:43 UTC, Frustrated wrote: Basically in programming to interfaces I need to decide to call a virtual method of an object if it exists else call a final method in the interface: interface A { static final void foo() { ... } } class B : A { void bar() {

Re: How to dynamically call class virtual method dynamically

2014-04-01 Thread John Colvin
On Tuesday, 1 April 2014 at 09:12:41 UTC, John Colvin wrote: Also, bear in mind that polymorphism is one-way: you can call base class methods through an inherited class reference, but not the other way around. Sorry, I should clarify that: Given an inheritance tree with the base class class

Re: Why is SysTime.init invalid?

2014-04-01 Thread Jonathan M Davis
On Tuesday, April 01, 2014 05:35:28 ed wrote: OK, lazy me just read the std.satetime article again. It appears the design is for no invalid values and it is currently a known limitation due to CTFE. --- d_time_nanThere is no equivalent. SysTime.init, which has a null TimeZone object,

Re: How to foreach over a DList?

2014-04-01 Thread Ali Çehreli
On 03/31/2014 10:32 PM, Jeroen Bollen wrote: Still no luck: import std.container; import std.stdio; void main() { DList!ubyte list1 = DList!ubyte(); list1 ~= cast(ubyte) 1; list1 ~= cast(ubyte) 2; list1 ~= cast(ubyte) 3; foreach(ubyte item; list1[]) {

Re: How to foreach over a DList?

2014-04-01 Thread John Colvin
On Tuesday, 1 April 2014 at 10:56:40 UTC, Ali Çehreli wrote: On 03/31/2014 10:32 PM, Jeroen Bollen wrote: Still no luck: import std.container; import std.stdio; void main() { DList!ubyte list1 = DList!ubyte(); list1 ~= cast(ubyte) 1; list1 ~= cast(ubyte) 2; list1 ~=

Re: How to foreach over a DList?

2014-04-01 Thread bearophile
John Colvin: doesn't work on 2.065 But it works in the latest alpha. Bye, bearophile

Re: How to dynamically call class virtual method dynamically

2014-04-01 Thread Steven Schveighoffer
On Tue, 01 Apr 2014 03:31:41 -0400, Frustrated w...@where.com wrote: Basically in programming to interfaces I need to decide to call a virtual method of an object if it exists else call a final method in the interface: interface A { static final void foo() { ... } } class B : A {

Re: How to foreach over a DList?

2014-04-01 Thread monarch_dodra
On Tuesday, 1 April 2014 at 10:56:40 UTC, Ali Çehreli wrote: On 03/31/2014 10:32 PM, Jeroen Bollen wrote: Still no luck: import std.container; import std.stdio; void main() { DList!ubyte list1 = DList!ubyte(); list1 ~= cast(ubyte) 1; list1 ~= cast(ubyte) 2; list1 ~=

Re: How to foreach over a DList?

2014-04-01 Thread Meta
On Tuesday, 1 April 2014 at 12:30:03 UTC, monarch_dodra wrote: I fixed this not too long ago. Long story short, the ~= implementations were made of fail. Just change those ~= for insertBack and you should be fine. That aside, why is it necessary to cast 1, 2 and 3 to ubyte when adding them

Re: How to foreach over a DList?

2014-04-01 Thread Steven Schveighoffer
On Tue, 01 Apr 2014 09:30:18 -0400, Meta jared...@gmail.com wrote: On Tuesday, 1 April 2014 at 12:30:03 UTC, monarch_dodra wrote: I fixed this not too long ago. Long story short, the ~= implementations were made of fail. Just change those ~= for insertBack and you should be fine. That

Re: How to foreach over a DList?

2014-04-01 Thread monarch_dodra
On Tuesday, 1 April 2014 at 13:30:21 UTC, Meta wrote: On Tuesday, 1 April 2014 at 12:30:03 UTC, monarch_dodra wrote: I fixed this not too long ago. Long story short, the ~= implementations were made of fail. Just change those ~= for insertBack and you should be fine. That aside, why is it

Re: How to foreach over a DList?

2014-04-01 Thread monarch_dodra
On Tuesday, 1 April 2014 at 13:54:00 UTC, monarch_dodra wrote: In contrast, if you *pass* 1 to the DList, you lose that info, and the DList will complain that you are trying to assign an int to a ubyte. EDIT: The issue is actually one of template constraint, but it's essentially equivalent.

Re: How to foreach over a DList?

2014-04-01 Thread H. S. Teoh
On Tue, Apr 01, 2014 at 06:04:48AM +, monarch_dodra wrote: On Tuesday, 1 April 2014 at 04:43:44 UTC, H. S. Teoh wrote: On Mon, Mar 31, 2014 at 09:55:01PM +, monarch_dodra wrote: On Monday, 31 March 2014 at 21:41:16 UTC, H. S. Teoh wrote: Argh, why is opSlice non-const? :-( Please file

Re: How to foreach over a DList?

2014-04-01 Thread Meta
On Tuesday, 1 April 2014 at 13:55:05 UTC, monarch_dodra wrote: On Tuesday, 1 April 2014 at 13:54:00 UTC, monarch_dodra wrote: In contrast, if you *pass* 1 to the DList, you lose that info, and the DList will complain that you are trying to assign an int to a ubyte. EDIT: The issue is

Re: How to foreach over a DList?

2014-04-01 Thread monarch_dodra
On Tuesday, 1 April 2014 at 15:16:41 UTC, Meta wrote: On Tuesday, 1 April 2014 at 13:55:05 UTC, monarch_dodra wrote: On Tuesday, 1 April 2014 at 13:54:00 UTC, monarch_dodra wrote: In contrast, if you *pass* 1 to the DList, you lose that info, and the DList will complain that you are trying to

Re: How to foreach over a DList?

2014-04-01 Thread Jeroen Bollen
Just for reference, this is the compiling code: https://gist.github.com/Binero/f30e56351baf05f1a2ec

Re: How to dynamically call class virtual method dynamically

2014-04-01 Thread Frustrated
On Tuesday, 1 April 2014 at 12:20:06 UTC, Steven Schveighoffer wrote: On Tue, 01 Apr 2014 03:31:41 -0400, Frustrated w...@where.com wrote: Basically in programming to interfaces I need to decide to call a virtual method of an object if it exists else call a final method in the interface:

Re: How to dynamically call class virtual method dynamically

2014-04-01 Thread anonymous
On Tuesday, 1 April 2014 at 19:00:18 UTC, Frustrated wrote: A a = new B; [...] Now suppose B implements That as a virtual method that doesn't exist in A. [...] e.g., typeof(cast(Object)a) returns B, right? No, it's Object. You're looking for typeid which returns a TypeInfo [1] which is

Re: template interface and delegates

2014-04-01 Thread anonymous
Is this bug allready reported? or can somebody who has a deeper insight to this report it? On Tuesday, 1 April 2014 at 05:51:46 UTC, anonymous wrote: Ok, thought i did something wrong or got some wrong idea how it should work.

Re: How to dynamically call class virtual method dynamically

2014-04-01 Thread Steven Schveighoffer
On Tue, 01 Apr 2014 15:00:17 -0400, Frustrated w...@where.com wrote: On Tuesday, 1 April 2014 at 12:20:06 UTC, Steven Schveighoffer wrote: On Tue, 01 Apr 2014 03:31:41 -0400, Frustrated w...@where.com wrote: Basically in programming to interfaces I need to decide to call a virtual method of

Re: template interface and delegates

2014-04-01 Thread Steven Schveighoffer
On Tue, 01 Apr 2014 15:47:42 -0400, anonymous n...@trash-mail.com wrote: Is this bug allready reported? or can somebody who has a deeper insight to this report it? I don't know. I think you should report it. If it's already reported, someone will close it as a duplicate -Steve

Re: How to dynamically call class virtual method dynamically

2014-04-01 Thread Frustrated
On Tuesday, 1 April 2014 at 19:52:47 UTC, Steven Schveighoffer wrote: On Tue, 01 Apr 2014 15:00:17 -0400, Frustrated w...@where.com wrote: On Tuesday, 1 April 2014 at 12:20:06 UTC, Steven Schveighoffer wrote: On Tue, 01 Apr 2014 03:31:41 -0400, Frustrated w...@where.com wrote: Basically in

Re: Why is SysTime.init invalid?

2014-04-01 Thread ed
On Tuesday, 1 April 2014 at 10:54:41 UTC, Jonathan M Davis wrote: On Tuesday, April 01, 2014 05:35:28 ed wrote: OK, lazy me just read the std.satetime article again. It appears the design is for no invalid values and it is currently a known limitation due to CTFE. --- d_time_nan There is no

Sockets between D and C(++) app

2014-04-01 Thread Alexandre L.
Hello, I lately did a minimal udp socket server-client application with C++, and I've been trying to recreate it with D, after. I'm able to get the client's request (C++ client) without too much trouble (after I figured I needed to get it in ubyte[]). Then I've tried to send the client an

Re: Sockets between D and C(++) app

2014-04-01 Thread bearophile
Alexandre L.: Some comments on your code: Here's my 'server' code: int main(string[] args) { If you don't need args, then I suggest to not put it as main argument. So probably this is better (note no int nor return, in D they are not needed): void main() { ... } int

Re: Sockets between D and C(++) app

2014-04-01 Thread Alexandre L.
On Wednesday, 2 April 2014 at 00:34:08 UTC, bearophile wrote: char[] rep = regan\0.dup; s.send(cast(ubyte[])rep); casts are dangerous, because they silently assume you know what you are doing. As first try I suggest you to remove every cast()

Re: Sockets between D and C(++) app

2014-04-01 Thread Alexandre L.
My bad; It returns immutable(char)*. Still won't work with send(); Am I right to supposed the receiving client must handle a ubyte[] as well (C++) ?