www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - pseudo array properties

reply Derek Parnell <derek nomail.afraid.org> writes:
In V2, were we meant to lose the (undocumented) facility to have pseudo
properties for arrays?

In other words, the code below compiled and ran for V1 but it doesn't for
V2.

char[] foo(char[] a) { return a; }
void main()
{
    char[] q;
    q = q.foo;  // Invoke 'foo' as if it were a property.
}


-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
6/07/2007 11:50:31 AM
Jul 05 2007
next sibling parent reply Charlie <charlie.fats gmail.com> writes:
That will be a serious loss.  This 'feature' was an awesome one, and a 
shame it never made it into the specs.

Derek Parnell wrote:
 In V2, were we meant to lose the (undocumented) facility to have pseudo
 properties for arrays?
 
 In other words, the code below compiled and ran for V1 but it doesn't for
 V2.
 
 char[] foo(char[] a) { return a; }
 void main()
 {
     char[] q;
     q = q.foo;  // Invoke 'foo' as if it were a property.
 }
 
 
Jul 05 2007
next sibling parent reply Jason House <jason.james.house gmail.com> writes:
Charlie wrote:
 That will be a serious loss.  This 'feature' was an awesome one, and a 
 shame it never made it into the specs.
Personally, I'd like to see it generalized to more than just arrays...
 
 Derek Parnell wrote:
 In V2, were we meant to lose the (undocumented) facility to have pseudo
 properties for arrays?

 In other words, the code below compiled and ran for V1 but it doesn't for
 V2.

 char[] foo(char[] a) { return a; }
 void main()
 {
     char[] q;
     q = q.foo;  // Invoke 'foo' as if it were a property.
 }
Jul 05 2007
parent reply Charlie <charlie.fats gmail.com> writes:
 Personally, I'd like to see it generalized to more than just arrays...
Yes me too. I guess we now have to convice Andrei , who will in turn convince Walter, since Walter has been ignoring our pleads lately. Jason House wrote:
 Charlie wrote:
 That will be a serious loss.  This 'feature' was an awesome one, and a 
 shame it never made it into the specs.
Personally, I'd like to see it generalized to more than just arrays...
 Derek Parnell wrote:
 In V2, were we meant to lose the (undocumented) facility to have pseudo
 properties for arrays?

 In other words, the code below compiled and ran for V1 but it doesn't 
 for
 V2.

 char[] foo(char[] a) { return a; }
 void main()
 {
     char[] q;
     q = q.foo;  // Invoke 'foo' as if it were a property.
 }
Jul 05 2007
parent Jari-Matti =?ISO-8859-1?Q?M=E4kel=E4?= <jmjmak utu.fi.invalid> writes:
Charlie wrote:

  > Personally, I'd like to see it generalized to more than just arrays...
 
 Yes me too.  I guess we now have to convice Andrei , who will in turn
 convince Walter, since Walter has been ignoring our pleads lately.
 
FWIW, this has been proposed before and nothing happened. For example Scala language generalizes it in a nice way.
Jul 08 2007
prev sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
 That will be a serious loss.  This 'feature' was an awesome one, and a 
 shame it never made it into the specs.
 
On the contrary, it's in the specs for both 1.0 and 2.0: http://www.digitalmars.com/d/arrays.html See under "Functions as Array Properties" Yes, I agree, it should be generalized to non-arrays. As I mentioned before, I love the natural feel of the Ruby-esque: --- import tango.io.Stdout; void times(int n, void delegate() action) { for(int i = 0; i < n; i++) action(); } void main { 3.times( { Stdout("Hello!").newline; }); } ---
Jul 05 2007
prev sibling next sibling parent reply Derek Parnell <derek nomail.afraid.org> writes:
On Fri, 6 Jul 2007 11:52:38 +1000, Derek Parnell wrote:

 In V2, were we meant to lose the (undocumented) facility to have pseudo
 properties for arrays?
 
 In other words, the code below compiled and ran for V1 but it doesn't for
 V2.
 
 char[] foo(char[] a) { return a; }
 void main()
 {
     char[] q;
     q = q.foo;  // Invoke 'foo' as if it were a property.
 }
Ok, maybe I got this wrong 'cos I can't get it to run in V1 either. Didn't we used to be able to do this? -- Derek (skype: derek.j.parnell) Melbourne, Australia 6/07/2007 12:17:14 PM
Jul 05 2007
parent Oskar Linde <oskar.lindeREM OVEgmail.com> writes:
Derek Parnell skrev:
 On Fri, 6 Jul 2007 11:52:38 +1000, Derek Parnell wrote:
 
 In V2, were we meant to lose the (undocumented) facility to have pseudo
 properties for arrays?

 In other words, the code below compiled and ran for V1 but it doesn't for
 V2.

 char[] foo(char[] a) { return a; }
 void main()
 {
     char[] q;
     q = q.foo;  // Invoke 'foo' as if it were a property.
 }
Ok, maybe I got this wrong 'cos I can't get it to run in V1 either. Didn't we used to be able to do this?
The limitation (that has always been there) is that for "pseudo properties", you need to call them with the trailing parentheses: q = q.foo(); // should work -- Oskar
Jul 05 2007
prev sibling parent Sean Kelly <sean f4.ca> writes:
Derek Parnell wrote:
 In V2, were we meant to lose the (undocumented) facility to have pseudo
 properties for arrays?
I think this was actually added to the spec for v1.0. Sean
Jul 06 2007