www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Properties and macros on WalterAndrei.pdf.

reply =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= writes:
Regarding slides 9 through 11 of WalterAndrei.pdf (Uniform Function Call 
      Syntax) would we be allowed to add properties to a class? For example:

void foo(Matrix m, char[] value)
{
	// ...
}
char[] foo(Matrix m)
{
	// ...
}

m.foo = "parrot";
writefln("It's a dead %s.", m.foo);	//-> It's a dead parrot.


Now on pages 45 - 51 on AST Macros... Would it be possible to declare a 
macro as a static member of a class or struct? Example:

struct Matrix
{
	macro foo(e) { e = 3; }
}

Matrix.foo(q);	// I didn't pick the names. Don't blame me for it. ;)

Thanks
Sep 05 2007
next sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
Julio CÚsar Carrascal Urquijo Wrote:

 Regarding slides 9 through 11 of WalterAndrei.pdf (Uniform Function Call 
       Syntax) would we be allowed to add properties to a class? For example:
 
 void foo(Matrix m, char[] value)
 {
 	// ...
 }
 char[] foo(Matrix m)
 {
 	// ...
 }
 
 m.foo = "parrot";
 writefln("It's a dead %s.", m.foo);	//-> It's a dead parrot.
 
 
 Now on pages 45 - 51 on AST Macros... Would it be possible to declare a 
 macro as a static member of a class or struct? Example:
 
 struct Matrix
 {
 	macro foo(e) { e = 3; }
 }
 
 Matrix.foo(q);	// I didn't pick the names. Don't blame me for it. ;)
 
 Thanks

I'm guessing probably not, as the current array-member-function syntax requires parens. I don't think it would make lookup _much_ harder, though.
Sep 05 2007
prev sibling parent Jason House <jason.james.house gmail.com> writes:
Julio CÚsar Carrascal Urquijo wrote:
 Regarding slides 9 through 11 of WalterAndrei.pdf (Uniform Function Call 
      Syntax) would we be allowed to add properties to a class? For example:
 
 void foo(Matrix m, char[] value)
 {
     // ...
 }
 char[] foo(Matrix m)
 {
     // ...
 }
 
 m.foo = "parrot";
 writefln("It's a dead %s.", m.foo);    //-> It's a dead parrot.
 
 
 Now on pages 45 - 51 on AST Macros... Would it be possible to declare a 
 macro as a static member of a class or struct? Example:
 
 struct Matrix
 {
     macro foo(e) { e = 3; }
 }
 
 Matrix.foo(q);    // I didn't pick the names. Don't blame me for it. ;)
 
 Thanks

I'm too tired/lazy to look it up, but I could swear that there was a line in there saying that this functionality would not extend to macros.
Sep 05 2007