I want to be able to write this:
define xml-rpc-server $my-server "/RPC2"
(error-fault-code: 1)
"echo" => method (#rest args) args end;
"ping" => method () "ack" end;
end;
Here's my attempt.
define macro xml-rpc-server-definer
{ define xml-rpc-server ?:name ?url:expression (?initargs:*) ?
functions end }
=> { define constant ?name = apply(make, <xml-rpc-server>, ?
initargs);
let _server = ?name;
add-responder(?url, curry(respond-to-xml-rpc-request,
_server));
?functions
}
functions:
{ } => { }
{ ?function; ... } => { ?function; ... }
function:
{ ?function-name:expression = ?fun:expression }
=>
{ register-xml-rpc-method(_server, ?function-name, ?fun) }
end macro xml-rpc-server-definer;
When I compile my example I get the unhelpful error message "invalid
syntax",
and I'm afraid that's all I have to go on. Can anyone spot the
problem?
Thanks.
-Carl
> { ?function-name:expression = ?fun:expression }
Shouldn't that be:
> { ?function-name:expression => ?fun:expression }
-Peter-
Yes, but that's just an artifact of my messing about to try and figure
out what the problem was. Even with => I still get the mysterious
"syntax error".
-Carl
The new definition below works. I just added parens around ?
url:expression. I wonder if it was greedily taking all of
"/RPC2"(error-fault-code: 1)
as the ?url expression? And if that's the case, I wonder why it
doesn't take all of
("/RPC2")(error-fault-code: 1)
as well. Black magic.
define macro xml-rpc-server-definer
{ define xml-rpc-server ?:name (?url:expression)
(?initargs:*)
?functions
end }
=> { define constant ?name = apply(make, <xml-rpc-server>,
?initargs);
begin
let _server = ?name;
add-responder(?url, curry(respond-to-xml-rpc-request,
_server));
?functions
end }
functions:
{ } => { }
{ ?function; ... } => { ?function; ... }
function:
{ ?function-name:expression => ?fun:expression; }