Re: How to call receiveTimout? (std.concurrency)

2010-06-29 Thread Heywood Floyd
Thanks! I will! /heywood PS. I like D. On Jun 29, 2010, at 19:37 , Steven Schveighoffer wrote: > On Tue, 29 Jun 2010 13:05:50 -0400, Heywood Floyd wrote: > >> >> >> Ok, thanks! >> >> How does the chain of command/responsibility work here? >> Should I file this to bugzilla? >> >> (I

Re: Mixing operations with signed and unsigned types

2010-06-29 Thread Stewart Gordon
bearophile wrote: Stewart Gordon: http://d.puremagic.com/issues/show_bug.cgi?id=259 I have added my vote there a lot of time ago. I think Andrei says that fixing this is unworkable, but I don't know why. If you make this an error and at the same time turn array indexes/lengths into signed v

Re: Mixing operations with signed and unsigned types

2010-06-29 Thread bearophile
Michal Minich: >Why on the earth should array indexes and lengths be signed !!! I have explained why lengthy elsewhere. Short answer: signed fixnum integers are a bad approximation of natural numbers, because they are limited in range, they don't even tell you when you try to step out of their

Re: dcollections how to LinkList // port c# code

2010-06-29 Thread bearophile
Byron Heads: > > this(string name, string id) { > > this._name = _name; > > this._id = id; > > } > > > > this._name = name; // you had _name I have just filed a bug report on this (it's a lot of time I want to write it)

Re: Mixing operations with signed and unsigned types

2010-06-29 Thread Stewart Gordon
Michal Minich wrote: I was surprised by the behavior of division. The resulting type of division in example below is uint and the value is incorrect. I would expect that when one of operands is signed, then the result is signed type. Going by the spec http://www.digitalmars.com/d/1.0/type.ht

Re: dcollections how to LinkList // port c# code

2010-06-29 Thread Byron Heads
Just a few things that may cause you some bugs/errors On Tue, 29 Jun 2010 23:33:13 +0200, BLS wrote: > On 29/06/2010 22:12, Steven Schveighoffer wrote: > // Confirm these are the same instance > if (b1 == b2 && b2 == b3 ) { > writeln("Same instance\n"); > } I think you m

Re: Mixing operations with signed and unsigned types

2010-06-29 Thread Michal Minich
On Wed, 30 Jun 2010 00:30:19 +0100, Stewart Gordon wrote: > Michal Minich wrote: >> I was surprised by the behavior of division. The resulting type of >> division in example below is uint and the value is incorrect. I would >> expect that when one of operands is signed, then the result is signed >

Re: Mixing operations with signed and unsigned types

2010-06-29 Thread Michal Minich
There is very long discussion on digitamars.D ng "Is there ANY chance we can fix the bitwise operator precedence rules?" which I should probably read first...but was there some conclusion ?

Re: Mixing operations with signed and unsigned types

2010-06-29 Thread Michal Minich
On Tue, 29 Jun 2010 19:42:45 -0400, bearophile wrote: > Stewart Gordon: >> http://d.puremagic.com/issues/show_bug.cgi?id=259 > > I have added my vote there a lot of time ago. I think Andrei says that > fixing this is unworkable, but I don't know why. If you make this an > error and at the same ti

Re: Mixing operations with signed and unsigned types

2010-06-29 Thread Michal Minich
On Tue, 29 Jun 2010 19:42:45 -0400, bearophile wrote: > Stewart Gordon: >> http://d.puremagic.com/issues/show_bug.cgi?id=259 > > I have added my vote there a lot of time ago. I think Andrei says that > fixing this is unworkable, but I don't know why. If you make this an > error and at the same ti

Re: Mixing operations with signed and unsigned types

2010-06-29 Thread bearophile
Stewart Gordon: > http://d.puremagic.com/issues/show_bug.cgi?id=259 I have added my vote there a lot of time ago. I think Andrei says that fixing this is unworkable, but I don't know why. If you make this an error and at the same time turn array indexes/lengths into signed values, you don't have

Mixing operations with signed and unsigned types

2010-06-29 Thread Michal Minich
I was surprised by the behavior of division. The resulting type of division in example below is uint and the value is incorrect. I would expect that when one of operands is signed, then the result is signed type. int a = -6; uint b = 2; auto c = a / b; // c is type of uint, and has v

Re: Class knowing its own Class

2010-06-29 Thread strtr
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article > On Tue, 29 Jun 2010 17:59:37 -0400, strtr wrote: > > What is the pretty way to do something like this? > > > > Class C > > { > > void makeNew() > > { > > new typeof(this); > > } > > } > As edited... > -Steve Whahaha! T

Class knowing its own Class

2010-06-29 Thread strtr
What is the pretty way to do something like this? Class C { private const char[] _name = "C";// demangling this.mangleof didn't work void makeNew() { mixin(`new `~_name~`();`); // the not so pretty part } }

Re: Class knowing its own Class

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 17:59:37 -0400, strtr wrote: What is the pretty way to do something like this? Class C { void makeNew() { new typeof(this); } } As edited... -Steve

Re: dcollections how to LinkList // port c# code

2010-06-29 Thread BLS
On 29/06/2010 23:49, Steven Schveighoffer wrote: One thing to note, ArrayList *does* accept an array as a constructor, and it will actually use that array as its storage. This is so you can "wrap" an array as a ArrayList and get the full dcollections functionality from it. Hi Steve This is why

Re: dcollections how to LinkList // port c# code

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 17:33:13 -0400, BLS wrote: On 29/06/2010 22:12, Steven Schveighoffer wrote: For now, can you do something like this? sl = new ServerList; sl.add([ new Server("ServerI", "120.14.220.18"), new Server(...) ... ]); Hi Steve, I think this should work, however I go

Re: dcollections how to LinkList // port c# code

2010-06-29 Thread BLS
On 29/06/2010 22:12, Steven Schveighoffer wrote: For now, can you do something like this? sl = new ServerList; sl.add([ new Server("ServerI", "120.14.220.18"), new Server(...) ... ]); Hi Steve, I think this should work, however I got very strange err. msg. in file ArrayList.d Hav

Re: dcollections how to LinkList // port c# code

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 15:22:30 -0400, BLS wrote: Hi, in C# this is common. private List _servers; _servers = new List { new Server{ Name = "ServerI", IP = "120.14.220.18" }, new Server{ Name = "ServerII", IP = "120.14.220.19" }, new Server{ Name = "Serve

Re: dcollections how to LinkList // port c# code

2010-06-29 Thread Byron Heads
On Tue, 29 Jun 2010 15:27:41 -0400, bearophile wrote: > In D use dynamic arrays unless you really need to remove or add a lot of > items from the start or middle of the sequence. On modern CPUs linked > lists are usually the wrong data structure to use. > > Bye, > bearophile D's dynamic arrays

Re: dcollections how to LinkList // port c# code

2010-06-29 Thread bearophile
BLS: > D2 so far.. > import dcollections.LinkList; In D use dynamic arrays unless you really need to remove or add a lot of items from the start or middle of the sequence. On modern CPUs linked lists are usually the wrong data structure to use. Bye, bearophile

dcollections how to LinkList // port c# code

2010-06-29 Thread BLS
Hi, in C# this is common. private List _servers; _servers = new List { new Server{ Name = "ServerI", IP = "120.14.220.18" }, new Server{ Name = "ServerII", IP = "120.14.220.19" }, new Server{ Name = "ServerIII", IP = "120.14.220.20" }, new Server{ Nam

Re: dcollections problem

2010-06-29 Thread BLS
On 29/06/2010 20:19, Steven Schveighoffer wrote: Are you linking against dcollections? It looks like you are not... No. BTW, you can use dcollections' ticket tracking system for things like this instead of sending to the newsgroup :) Will do. Thanks Steve bjoern

Re: dcollections problem

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 14:13:57 -0400, BLS wrote: Hi - probably Steve :) I have problem in compiling a little programm using dcollection.LinkList. (similar problem appears when I use dcollections.ArrayList) D2.047 Linker error.. Error 1 Error 42: Symbol Undefined _D12dcollections8LinkL

dcollections problem

2010-06-29 Thread BLS
Hi - probably Steve :) I have problem in compiling a little programm using dcollection.LinkList. (similar problem appears when I use dcollections.ArrayList) D2.047 Linker error.. Error 1 Error 42: Symbol Undefined _D12dcollections8LinkList7__arrayZ Error 2 Error 42: Symbol

Re: How to call receiveTimout? (std.concurrency)

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 13:05:50 -0400, Heywood Floyd wrote: Ok, thanks! How does the chain of command/responsibility work here? Should I file this to bugzilla? (I'm not able to fix it myself as I haven't built dmd locally. I'm just not quite there yet... : ) /heywood Simen actually alre

Re: How to call receiveTimout? (std.concurrency)

2010-06-29 Thread Heywood Floyd
Ok, thanks! How does the chain of command/responsibility work here? Should I file this to bugzilla? (I'm not able to fix it myself as I haven't built dmd locally. I'm just not quite there yet... : ) /heywood On Jun 29, 2010, at 16:31 , Steven Schveighoffer wrote: > On Tue, 29 Jun 2010 09:5

Re: @property and interfaces

2010-06-29 Thread BLS
On 29/06/2010 17:03, Rory McGuire wrote: @disable propagates throughout the objects hierarchy (all children). you can use it to disable builtins as well such as opEquals Cool, thanks Rory!

Re: @property and interfaces

2010-06-29 Thread Rory McGuire
On Tue, 29 Jun 2010 14:42:33 +0200, BLS wrote: Hi bearophile, sorry for my ignorance, but what is the difference between @disable and simply deleting the line ? where can I read more about @disable ? thanks, bjoern @disable propagates throughout the objects hierarchy (all children). you c

How to call receiveTimout? (std.concurrency)

2010-06-29 Thread soul8o8
Hello! I'm trying to use receiveTimeout: // import std.stdio, std.concurrency; int main(string[] args){ receiveTimeout( 1000L, (int i){writefln("Received: %d",i);} ) ; return 0; } // (

Re: How to call receiveTimout? (std.concurrency)

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 09:53:25 -0400, Simen kjaeraas wrote: Heywood Floyd wrote: ops = ops[1 .. $]; // <=== line 335 Well, this looks like a bug to me. Should be Ops = ops[1 .. $]; Ops is a type, isn't it? Don't you need a variable there? I agree it's a bug in the original, but I do

Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 09:55:50 -0400, BLS wrote: On 29/06/2010 15:35, BLS wrote: On 29/06/2010 15:27, Steven Schveighoffer wrote: string opIndex(string columnName); yeah this is what I did, too.. However defined as ; interface I1 { string opIndex(string columnName); } is a no go. So can we

Re: How do I make an extern function?

2010-06-29 Thread BCS
Hello Simen, BCS wrote: You can resolve this by having a a.di file with the extern foo(); in it (DMD has a flag to generate such a file for you). OTOH without knowing what you are doing, I can't tell if this is the correct solution. I'm trying to create a framework in which the user may

Re: How to call receiveTimout? (std.concurrency)

2010-06-29 Thread Simen kjaeraas
Simen kjaeraas wrote: Heywood Floyd wrote: ops = ops[1 .. $]; // <=== line 335 Well, this looks like a bug to me. Should be Ops = ops[1 .. $]; Oh, and you could probably make this change yourself. -- Simen

Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread BLS
On 29/06/2010 15:35, BLS wrote: On 29/06/2010 15:27, Steven Schveighoffer wrote: string opIndex(string columnName); yeah this is what I did, too.. However defined as ; interface I1 { string opIndex(string columnName); } is a no go. So can we say operator overloading within interfaces is not

Re: How to call receiveTimout? (std.concurrency)

2010-06-29 Thread Simen kjaeraas
Heywood Floyd wrote: ops = ops[1 .. $]; // <=== line 335 Well, this looks like a bug to me. Should be Ops = ops[1 .. $]; -- Simen

Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread Trass3r
interface I1 { string opIndex(string columnName); } is a no go. So can we say operator overloading within interfaces is not allowed in D2 ? It should work. Only opBinary etc doesn't work yet cause there are problems with template functions in interfaces.

How to call receiveTimout? (std.concurrency)

2010-06-29 Thread Heywood Floyd
Hello and Good morning! I'm trying to use receiveTimeout: // import std.stdio, std.concurrency; int main(string[] args){ receiveTimeout( 1000L, (int i){writefln("Received: %d",i);} ) ; return 0; } // ���

Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread Simen kjaeraas
BLS wrote: On 29/06/2010 15:27, Steven Schveighoffer wrote: string opIndex(string columnName); yeah this is what I did, too.. However defined as ; interface I1 { string opIndex(string columnName); } is a no go. Hm. That should have worked. So can we say operator overloading within in

Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread BLS
On 29/06/2010 15:27, Steven Schveighoffer wrote: string opIndex(string columnName); yeah this is what I did, too.. However defined as ; interface I1 { string opIndex(string columnName); } is a no go. So can we say operator overloading within interfaces is not allowed in D2 ? thanks again

Re: C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 09:21:34 -0400, BLS wrote: Hi, in C# you can do some thing like this. public interface IDataErrorInfo { // INDEXER string this[string columnName] { get; } } } how to translate this into D2 ? thanks in advance, bjoern string opIndex(string columnName);

C# Indexers. how to implement them in D.. also property related.

2010-06-29 Thread BLS
Hi, in C# you can do some thing like this. public interface IDataErrorInfo { // INDEXER string this[string columnName] { get; } } } how to translate this into D2 ? thanks in advance, bjoern

Re: @property and interfaces

2010-06-29 Thread BLS
Hi bearophile, sorry for my ignorance, but what is the difference between @disable and simply deleting the line ? where can I read more about @disable ? thanks, bjoern

Re: @property and interfaces

2010-06-29 Thread BLS
On 29/06/2010 14:08, Steven Schveighoffer wrote: Besides, try to do this in C#: @property int value() {return _x;} @property int value(int x) { return _x = x;} @property int value(string s) { return _x = to!int(s);} :) D's properties are so much better... -Steve Ok, convinced ;)

Re: @property and interfaces

2010-06-29 Thread bearophile
BLS: > But this one NOT. > > interface IBindingList { > > @property bool AllowEdit(); > @property bool AllowEdit(bool enable); > } > class A : IBindingList { > private bool _allowEdit; > > @property { > bool AllowEdit() { return _allowEdit; }

Re: @property and interfaces

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 06:58:54 -0400, BLS wrote: On 29/06/2010 12:32, Jonathan M Davis wrote: So, there certainly won't be any restriction on having a getter or setter in a class if an interface it implements declared only one. It's just that you'll only be able to use the one that's part of

Re: Grokking std.container and Ranges

2010-06-29 Thread Steven Schveighoffer
On Mon, 28 Jun 2010 23:01:42 -0400, Mike Parker wrote: I thought I understood ranges until I actually started trying to use them. Now I'm having difficulties with the new range-based containers. So I've got two issues right now, grokking ranges and understanding the container interfaces.

Re: How do I make an extern function?

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 06:24:42 -0400, Simen kjaeraas wrote: BCS wrote: The issue is that the function called from module a is _D1a3fooFZv where the function defined in module b is _D1b3fooFZv ('a' <-> 'b') so they aren't the same function. extern(C) works because C doesn't mangle names so

Re: @property and interfaces

2010-06-29 Thread BLS
On 29/06/2010 12:32, Jonathan M Davis wrote: So, there certainly won't be any restriction on having a getter or setter in a class if an interface it implements declared only one. It's just that you'll only be able to use the one that's part of the interface if you're using a reference of the inte

Re: @property and interfaces

2010-06-29 Thread Jonathan M Davis
On Tuesday 29 June 2010 03:11:34 BLS wrote: > Just wonder how to translate this C# snippet into D.. > //C# > public interface IBindingList { > > bool AllowEdit { >get; > } > } > > //D2 > interface IBindingList { > > @property bool allowEdit(); > } > > Is this correct

Re: @property and interfaces

2010-06-29 Thread BLS
sorry for making so much noise.. figured it out by myse4lf. interface IBindingList { @property bool AllowEdit(); //@property bool AllowEdit(bool enable); //remove // to enable setter } class A : IBindingList { private bool _allowEdit; @pro

Re: How do I make an extern function?

2010-06-29 Thread Simen kjaeraas
BCS wrote: The issue is that the function called from module a is _D1a3fooFZv where the function defined in module b is _D1b3fooFZv ('a' <-> 'b') so they aren't the same function. extern(C) works because C doesn't mangle names so the function is foo in both cases. I know. I just react to

@property and interfaces

2010-06-29 Thread BLS
Just wonder how to translate this C# snippet into D.. //C# public interface IBindingList { bool AllowEdit { get; } } //D2 interface IBindingList { @property bool allowEdit(); } Is this correct ? I think in C# AllowEdit() takes tare that you don't implement a s

Re: Grokking std.container and Ranges

2010-06-29 Thread Rory McGuire
On Tue, 29 Jun 2010 07:16:13 +0200, BCS wrote: Hello Mike, I want to do the following: foreach(obj; list) { if(obj.pleaseKillMe) somehow_remove_the_object_from_the_list(); } That isn't legal for normal arrays or AAs. IIRC the docs even say that you can't change what a foreach is iterating