Re: Grokking std.container and Ranges

2010-06-29 Thread Rory McGuire
On Tue, 29 Jun 2010 07:16:13 +0200, BCS n...@anon.com 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

@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

Re: How do I make an extern function?

2010-06-29 Thread Simen kjaeraas
BCS n...@anon.com 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

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;

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 ? I think in

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

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 simen.kja...@gmail.com wrote: BCS n...@anon.com 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

Re: Grokking std.container and Ranges

2010-06-29 Thread Steven Schveighoffer
On Mon, 28 Jun 2010 23:01:42 -0400, Mike Parker aldac...@gmail.com 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

Re: @property and interfaces

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 06:58:54 -0400, BLS windev...@hotmail.de 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

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 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 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

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: 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 windev...@hotmail.de 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

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

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

2010-06-29 Thread Simen kjaeraas
BLS windev...@hotmail.de 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

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 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.

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

2010-06-29 Thread Simen kjaeraas
Heywood Floyd soul...@gmail.com 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 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
Simen kjaeraas simen.kja...@gmail.com wrote: Heywood Floyd soul...@gmail.com 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: How do I make an extern function?

2010-06-29 Thread BCS
Hello Simen, BCS n...@anon.com 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

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 windev...@hotmail.de 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); }

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

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 09:53:25 -0400, Simen kjaeraas simen.kja...@gmail.com wrote: Heywood Floyd soul...@gmail.com 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

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; } // (I

Re: @property and interfaces

2010-06-29 Thread Rory McGuire
On Tue, 29 Jun 2010 14:42:33 +0200, BLS windev...@hotmail.de 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

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

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

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 13:05:50 -0400, Heywood Floyd soul...@gmail.com 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

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: dcollections problem

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 14:13:57 -0400, BLS windev...@hotmail.de 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

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

dcollections how to LinkList // port c# code

2010-06-29 Thread BLS
Hi, in C# this is common. private ListServer _servers; _servers = new ListServer { 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{

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

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 are

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

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

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 Have

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

2010-06-29 Thread Steven Schveighoffer
On Tue, 29 Jun 2010 17:33:13 -0400, BLS windev...@hotmail.de 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

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

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 st...@sp.am wrote: What is the pretty way to do something like this? Class C { void makeNew() { new typeof(this); } } As edited... -Steve

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 st...@sp.am wrote: What is the pretty way to do something like this? Class C { void makeNew() { new typeof(this); } } As edited... -Steve Whahaha! Thanks, I

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

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

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 time

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 time

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 type.

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 mean to

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 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

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: 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 soul...@gmail.com wrote: Ok, thanks! How does the chain of command/responsibility work here? Should I file this to bugzilla?