Home > Archive > Dylan > December 2004 > Q: build compound names in macros
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Q: build compound names in macros
|
|
| Michael Erdmann 2004-12-12, 8:55 pm |
| I have the following macro:
define macro frame-setter
{ frame-setter( ?clsname:name, ?members ) } => { ?members } ;
members:
{ } => { }
{ ?member , ... } => { ?member ... } ;
member:
{ ?:name } => {
define method setter-?name( value, this ) end;
define method ?name( this ) => ( <object> ) end;
} ;
end macro ;
this macro is intended to construct specific setter and
getter method. But it does not work since in setter-?name
the ?name is simply not subsitutted. In the DRM i found
name-prefix ? name name-suffix.
There for this would be a valid construct. What is wrong?
Michael
| |
| Michael Erdmann 2004-12-13, 8:58 pm |
| Michael Erdmann wrote:
> I have the following macro:
>
.......................
>
> member:
> { ?:name } => {
> define method setter-?name( value, this ) end;
> define method ?name( this ) => ( <object> ) end;
> } ;
>
> end macro ;
>
> this macro is intended to construct specific setter and
> getter method. But it does not work since in setter-?name
> the ?name is simply not subsitutted. In the DRM i found
>
> name-prefix ? name name-suffix.
>
This problem has been solved. The same macro look now like this:
define macro frame-accessor
{ frame-accessor( ?clsname:name, ?members ) } => { ?members } ;
members:
{ } => { }
{ ?member , ... } => { ?member ... } ;
member:
{ ?:name } => {
define method "setter-"##?name( value, this ) end;
define method ?name( this ) => ( <object> ) end;
} ;
end macro ;
_BUT_ there is still a problem. In order to make the methods
valid i need to restrict the type of this, which means
member:
{ ?:name } => {
define method "setter-"##?name( value, this :: ?clsname ) end;
define method ?name( this :: ?clsname ) => ( <object> ) end;
} ;
which leads to:
[Loading library format-out...]]
Parsing ma.dylan
"ma.dylan", line 35, characters 58 through 64:
define method "setter-"##?name( value, this :: ?clsname ) end;
^^^^^^^
Error: Unbound pattern variable: clsname
skipping rest of ma.dylan
Is there any way to pass from the main rule a
variable into aux. rules?
> There for this would be a valid construct. What is wrong?
>
> Michael
|
|
|
|
|