guile-user
[Top][All Lists]
Advanced

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

Re: make-module question.


From: Ian Hulin
Subject: Re: make-module question.
Date: Sat, 04 Sep 2010 22:10:41 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b3pre Thunderbird/3.1.2

Hi Andy,

On 29/08/10 20:05, Andy Wingo wrote:
> Greets,
> 
> On Wed 18 Aug 2010 14:35, Ian Hulin <address@hidden> writes:
> 
>> On 18/08/10 15:03, Ludovic Courtès wrote:
>>> Ian Hulin <address@hidden> writes:
>>>> Also what are the args the REPL says you can supply to (make-module) ?.
> 
>> It looks like there are three optional parameters, and the code is
>> trying to do a home-grown version of (ice-9 optargs) [...]
> 
> In git, the definition begins:
> 
> (define* (make-module #:optional (size 31) (uses '()) (binder #f))
>   ...)
> 
>> As the lilypond C++ routine immediately adds stuff to the uses list it
>> could be useful to call make-module with this parameter.
>> However, how do you call the thing while getting it to accept that you
>> don't want to pass it the first parameter and want to let it default the
>> value, but the first positional one you are passing is actually the
>> second actual one, as you don't have any list separators in Scheme like
>> in C++, or Pascal or whatever. So Scheme cannot distinguish between
>> (make-module ( my-obarray-size)) and (make-module ( my-uses-list))
>> whereas a language with list-element separators could make this clear
>> make-module ( my_obbaray_size, , );
>> and make-module ( , my_uses_list ,  );
> 
> You use #:key instead of #:optional arguments. make-module needs to be
> declared to have #:key arguments, though, which is not currently the
> case.
> 
Then I have two questions;
If #:key is a superset of #:optional, and allows you to specify
parameters positionally without the keywords if you're omitting
parameters from the right-hand end
(make-module my_obarray-size my_uses_list)
or
(make-module my_obarray-size)
but if you omit the size or uses parameter you have to use keywords
(make-module #:uses '((ice-9 syncase) (ice-9 debug))).
If this is the case, could I request an enhancement for this the base
code to declared using
(define* (make-module #:key (size 31) (uses '()) (binder #f))
   ...)
If make-module is declared using #;key, how would this affect calling it
from code with scm_call_1, scm_call_2, scm_call_3 or scm_call_n?  Would
we need to pass the keywords as separate parameters like this,

SCM scm_make_module_x = SCM_EOL;
SCM keyname = scm_str2symbol ("#;uses");
SCM modlist = scm_list_2 (scm_str2sym("ice-9 syncase"),
 scm_str2sym("ice-9 debug"))
scm_permanent_object (scm_c_lookup ("make-module"));
scm_call_2( SCM_VARIABLE_REF (scm_make_module_x), keyname, modlist):

or like this, with a place-holder blank parameter for the size parameter
with SCM_EOL or SCM_BOOL_F?

scm_call_2 (SCM_VARIABLE_REF (scm_make_module_x), SCM_BOOL_F, modlist);

Cheers,
Ian Hulin






reply via email to

[Prev in Thread] Current Thread [Next in Thread]