[Prev][Next][Index][Thread]

Critique this macro, please



So, I'm trying to create a function macro that returns a deferred
function.  Or, in functional terms:

begin
  with("foo.txt", do: parse-foo);
end;

define method parse-foo(a-line :: <string>)
  *foo* := a-line;
end method parse-foo;

(Where "with" reads in a file one line at a time and drops lines
starting with '#').  I have a bunch of these parse-foo's so I wanted to
create a macro, thus:

define macro parse-string
  { parse-string(?var:variable) }
    => { method(x) ?var := x; end }
end macro parse-string;

... and then call it like so:

begin
  with("foo.txt", do: parse-string(*foo*));
end;

The problem is that the compiler (d2c) complains:

No applicable methods in call of {GF build-defn-ref} when given
arguments:
  #[{<internal-fer-builder> instance},
    {<policy> 0xef5a8400,
       speed: 1.0s0,
       space: 1.0s0,
       safety: 1.0s0,
       brevity: 1.0s0,
       debug: 1.0s0},
    {<file-source-location> 0xeddf9618,
       source-file: {<source-file> 0xeee98780, name:
"file-parser.dylan"},
       start-line: 22,
       start-column: 46,
       end-line: 22,
       end-column: 58},
    {<function-macro-definition> 0xee844268,
       name:
         {<basic-name> 0xeee14dc0,
            symbol: #"parse-string",
            module: {<module> 0xeed56e10, name: #"file-parser"}}}]

(where the "with" statement is at line 22, and the parse-string macro
starts at column 46).

Something horribly wrong with my macro definition?  Please help.

Sincerely,
Doug Auclair


Sent via Deja.com
http://www.deja.com/



Follow-Ups: