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

Re: Another one: strings in method definitions?



In article <874s87i1m0.fsf@ethereal.dyndns.org>, Nolan Darilek
<nolan@ethereal.dhis.org> wrote:

> I have the following method definition:
> 
> define method output-c-type
>      (value :: <c-pointer-type>, name :: <string> = "anonymous", #key
anonymous = #t)
>  => (result :: <string>)
> 
> But, that doesn't work; d2c complains that none of the main method
> definition rules work. Removing the default value for name compiles,
> but that isn't what I want. I tried 'make(<string>, "anonymous")' and
> as(<string>, "anonymous") with no luck.
> 
> What obvious point am I missing now? :)

It should be (ignoring the keyword):

define method output-c-type
     (value :: <c-pointer-type>, name == "anonymous")

... or ...

define method output-c-type
     (value :: <c-pointer-type>, name :: singleton("anonymous"))


Basically, "name" isn't of type "string", it's of type "this 'ere
particular string".  The 'name == "anonymous"' syntax is just ahandy
shortcut for the real thing, which is the one using the "singleton"
function.

-- Bruce



Follow-Ups: References: