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

Re: Another one: strings in method definitions?



On Tue, 9 May 2000 22:30:02    Nolan Darilek 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? :)
>
>Thanks.

Hi Nolan,

Your problem is just that all non-keyword arguments in Dylan are
required, so the compiler won't allow you to provide a default for
them. There is no equivalent of the Common Lisp '&optional' in
Dylan, mainly because it can lead to strange bugs when combining
optional arguments with keyword arguments.

So you should probably just change your code to read:

define method output-c-type
     (value :: <c-pointer-type>, 
      #key name :: <string> = "anonymous",
           anonymous = #t)
 => (result :: <string>);

Hope that helps,

Andy

---
Andy Armstrong
andrewa@functionalobjects.com



Get your FREE Email at http://mailcity.lycos.com
Get your PERSONALIZED START PAGE at http://my.lycos.com