Code Comments
Programming Forum and web based access to our favorite programming groups.Hallo,
i am trying to create a macro called frame, which shall allow
the following statement;
define frame test-frame
field color;
field size;
end ;
When i compile the fragment below i get an error:
Inside expansion of ``define frame'' macro.
"ma.dylan", line 33, character 3 through line 35, character 5:
define frame test-frame
^^^^^^^^^^^^^^^^^^^^^^^
through
end ;
^^^^^
Error: Parse error at or before left brace
.......
I have some questions about it:
Q.1 I found out that the problem seems to be connected
to the {?fields} variable in make-frame-(....,..).
but i expected the fields rewrite to produce a
result like add-field(#"color"), add-field(#"size")
which would produce an argument list for make-frame
What is wrong?
Q.2 How can i debug such thing. With C i can run the
the preprocessor and check the result of any macro
expansion. Does d2c allow such a thing?
Regard
Michael
-------------------------------------------------------
module: ma
synopsis:
author:
copyright:
define method make-frame( name, #rest args ) => ( )
format-out("Name=%s, args=%=\n", name, args );
end method;
define method add-field( args ) => ( <string> )
format-out("Field=%=\n", args );
args;
end method;
define macro frame-definer
{ define frame ?:name ?fields end } => { make-frame( ?#"name",
{?fields} ) } ;
fields:
{ } => { }
{ ?field; ... } => { ?field, ... }
field:
{ field ?:name } => { add-field({?#"name"}) } ;
end macro ;
define function main(name, arguments)
format-out("Hello, world!\n");
define frame test-frame
field x ;
end ;
exit-application(0);
end function main;
// Invoke our main() function.
main(application-name(), application-arguments());
Post Follow-up to this messageMichael Erdmann wrote:
> Hallo,
This problem has been solved. But the Q.2 still remains!
>
> i am trying to create a macro called frame, which shall allow
> the following statement;
>
> define frame test-frame
> field color;
> field size;
> end ;
>
> When i compile the fragment below i get an error:
>
> Inside expansion of ``define frame'' macro.
> "ma.dylan", line 33, character 3 through line 35, character 5:
> define frame test-frame
> ^^^^^^^^^^^^^^^^^^^^^^^
> through
> end ;
> ^^^^^
> Error: Parse error at or before left brace
> .......
>
>
> I have some questions about it:
>
> Q.1 I found out that the problem seems to be connected
> to the {?fields} variable in make-frame-(....,..).
> but i expected the fields rewrite to produce a
> result like add-field(#"color"), add-field(#"size")
> which would produce an argument list for make-frame
> What is wrong?
>
> Q.2 How can i debug such thing. With C i can run the
> the preprocessor and check the result of any macro
> expansion. Does d2c allow such a thing?
>
>
> Regard
> Michael
>
>
> -------------------------------------------------------
> module: ma
> synopsis:
> author:
> copyright:
>
>
> define method make-frame( name, #rest args ) => ( )
> format-out("Name=%s, args=%=\n", name, args );
> end method;
>
> define method add-field( args ) => ( <string> )
> format-out("Field=%=\n", args );
> args;
> end method;
>
>
> define macro frame-definer
> { define frame ?:name ?fields end } => { make-frame( ?#"name",
> {?fields} ) } ;
>
> fields:
> { } => { }
> { ?field; ... } => { ?field, ... }
>
> field:
> { field ?:name } => { add-field({?#"name"}) } ;
>
> end macro ;
>
>
> define function main(name, arguments)
> format-out("Hello, world!\n");
>
> define frame test-frame
> field x ;
> end ;
>
> exit-application(0);
> end function main;
>
> // Invoke our main() function.
> main(application-name(), application-arguments());
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
Post Follow-up to this messageMichael, in Functional Developer you can see macro expansions by using the Project -> Macroexpand Selection menu item, after compiling your project. I don't know if d2c has anything equivalent. -Carl
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.