Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Q: Macro expnasion does not work, what is wrong?
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());


















Report this thread to moderator Post Follow-up to this message
Old Post
Michael Erdmann
12-11-04 01:55 PM


Re: Q: Macro expnasion does not work, what is wrong?
Michael 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());
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Michael Erdmann
12-13-04 01:55 AM


Re: Q: Macro expnasion does not work, what is wrong?
Michael, 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


Report this thread to moderator Post Follow-up to this message
Old Post
cgay
12-14-04 08:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Dylan archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:47 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.