This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Optional Arguments


James Dean Palmer <james@tiger-marmalade.com> writes:

> In the project I am working on, I am wanting to use optional
> arguments like:
> 
> (foo bar #:x 100 #:y 200)
> 
> where foo is a c procedure.  I thought the easiest way to handle this
> would be to make foo a procedure with one required argument, bar, and
> one rest argument, and then to parse the rest list for value pairs.
> But I guess I don't know how to do this --  What are #:x and #:y in c?
> I can't do a SCM_CHARS() to find out what they are (and yet, I can
> gh_display() them)
> 
> Any help or advice appreciated,

In Scwm, we make our C procedures not do any fancy argument processing,
and wrap those that do need optional or keyword arguments with a scheme
procedure (using Maciej's optargs.scm) that fills in the missing
arguments with #f.  Then there is only one implementation of fancy
argument processing, and primitives written in C are easier to manage.

Greg