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

Re: Another one: strings in method definitions?



In article <UOdS4.10804$Ft1.422737@typhoon.ne.mediaone.net>, "Scott McKay"
<swm@mediaone.net> wrote:

> Bruce Hoult wrote in message ...
> >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"))
> >
> 
> 
> Um, better watch out if you're trying to use \== on strings!

Um:

- don't have much choice as we don't have predicate specialisers

- it depends on what you're trying to do here, of which I've really got no
clue given just a single buggy method definition

- maybe someone went and made string functional (damn good idea, if you ask me)

- maybe it should be using a symbol instead of a string


It's time for bed.

-- Bruce



References: