Re: Generic collection/element function signatures in D2 versus D1

2010-09-11 Thread Nick Sabalausky
Jacob Carlborg d...@me.com wrote in message news:i5t61q$2j7...@digitalmars.com... If you're not going to modify the content of the array I think this will work: void foo (T) (const(T)[] collection, T elem) {} This will allow both mutable, immutable and const arrays. But it will not let

Re: Generic collection/element function signatures in D2 versus D1

2010-09-11 Thread Brad Roberts
On 9/11/2010 9:32 PM, Nick Sabalausky wrote: Jacob Carlborg d...@me.com wrote in message news:i5t61q$2j7...@digitalmars.com... If you're not going to modify the content of the array I think this will work: void foo (T) (const(T)[] collection, T elem) {} This will allow both mutable,

Re: Generic collection/element function signatures in D2 versus D1

2010-09-08 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 14:06:58 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Tue, 07 Sep 2010 11:37:20 -0400, Pelle pelle.mans...@gmail.com wrote: On 09/07/2010 04:33 PM, Steven Schveighoffer wrote: Yes, a valid return. Your function should be: void foo(void delegate(const(C)

Re: Generic collection/element function signatures in D2 versus D1

2010-09-08 Thread Pelle
On 09/08/2010 02:24 PM, Steven Schveighoffer wrote: On Tue, 07 Sep 2010 14:06:58 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Tue, 07 Sep 2010 11:37:20 -0400, Pelle pelle.mans...@gmail.com wrote: On 09/07/2010 04:33 PM, Steven Schveighoffer wrote: Yes, a valid return. Your

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Jacob Carlborg
On 2010-09-07 14:49, Steven Schveighoffer wrote: On Sun, 05 Sep 2010 09:40:59 -0400, BLS windev...@hotmail.de wrote: On 05/09/2010 02:16, Jonathan M Davis wrote: void foo(T)(T[] collection, T elem) { // Blah, whatever } I am curious, how this will look and feel once inout is working ?

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg d...@me.com wrote: On 2010-09-07 14:49, Steven Schveighoffer wrote: On Sun, 05 Sep 2010 09:40:59 -0400, BLS windev...@hotmail.de wrote: On 05/09/2010 02:16, Jonathan M Davis wrote: void foo(T)(T[] collection, T elem) { // Blah, whatever }

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Pelle
On 09/07/2010 03:15 PM, Steven Schveighoffer wrote: On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg d...@me.com wrote: On 2010-09-07 14:49, Steven Schveighoffer wrote: On Sun, 05 Sep 2010 09:40:59 -0400, BLS windev...@hotmail.de wrote: On 05/09/2010 02:16, Jonathan M Davis wrote: void

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 09:28:18 -0400, Pelle pelle.mans...@gmail.com wrote: On 09/07/2010 03:15 PM, Steven Schveighoffer wrote: On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg d...@me.com wrote: On 2010-09-07 14:49, Steven Schveighoffer wrote: On Sun, 05 Sep 2010 09:40:59 -0400, BLS

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Pelle
On 09/07/2010 04:33 PM, Steven Schveighoffer wrote: Yes, a valid return. Your function should be: void foo(void delegate(const(C) f) const It helps to understand that inout/const/immutable has NOTHING to do with code generation, it only has to do with limiting what compiles. For this reason,

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 11:37:20 -0400, Pelle pelle.mans...@gmail.com wrote: On 09/07/2010 04:33 PM, Steven Schveighoffer wrote: Yes, a valid return. Your function should be: void foo(void delegate(const(C) f) const It helps to understand that inout/const/immutable has NOTHING to do with code

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Jacob Carlborg
On 2010-09-07 17:37, Pelle wrote: On 09/07/2010 04:33 PM, Steven Schveighoffer wrote: Yes, a valid return. Your function should be: void foo(void delegate(const(C) f) const It helps to understand that inout/const/immutable has NOTHING to do with code generation, it only has to do with

Re: Generic collection/element function signatures in D2 versus D1

2010-09-05 Thread BLS
On 05/09/2010 02:16, Jonathan M Davis wrote: void foo(T)(T[] collection, T elem) { // Blah, whatever } I am curious, how this will look and feel once inout is working ? inout void foo(T)(inout(T)[] collection, inout T elem) { // Blah, whatever} }

Generic collection/element function signatures in D2 versus D1

2010-09-04 Thread Nick Sabalausky
In D1 I did this sort of thing a fair amount: void foo(T)(T[] collection, T elem) { // Blah, whatever } Worked for any of the string types, worked for any array, or anything with the appropriate opIndexes, and for all I know there may be some improvement that could still be made. But of

Re: Generic collection/element function signatures in D2 versus D1

2010-09-04 Thread Nick Sabalausky
Nick Sabalausky a...@a.a wrote in message news:i5su5e$23m...@digitalmars.com... In D1 I did this sort of thing a fair amount: void foo(T)(T[] collection, T elem) { // Blah, whatever } Worked for any of the string types, worked for any array, or anything with the appropriate

Re: Generic collection/element function signatures in D2 versus D1

2010-09-04 Thread Jacob Carlborg
On 2010-09-04 10:02, Nick Sabalausky wrote: Nick Sabalauskya...@a.a wrote in message news:i5su5e$23m...@digitalmars.com... In D1 I did this sort of thing a fair amount: void foo(T)(T[] collection, T elem) { // Blah, whatever } Worked for any of the string types, worked for any array, or

Re: Generic collection/element function signatures in D2 versus D1

2010-09-04 Thread Jonathan M Davis
On Saturday 04 September 2010 00:57:48 Nick Sabalausky wrote: In D1 I did this sort of thing a fair amount: void foo(T)(T[] collection, T elem) { // Blah, whatever } Worked for any of the string types, worked for any array, or anything with the appropriate opIndexes, and for all I