[Top][All Lists]

[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: Wed, 18 Aug 2010 22:35:33 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2

Hi Ludo,
On 18/08/10 15:03, Ludovic � wrote:
> Hi!
> Ian Hulin <address@hidden> writes:
>> (make-module) doesn't seem to appear in the documentation,  Is it
>> supported, discouraged or deprecated?
> It is undocumented but safe to use.
>> Is there a supported scm_make_module  we can use in the Guile API, and
>> if not, is it safe to use
>> SCM scm_make_module_x = SCM_EOL;
>> scm_permanent_object (scm_c_lookup ("make-module"));
>>  and then do
>> scm_call_0( SCM_VARIABLE_REF (scm_make_module_x)):
>> ?
> Yes, you can do this.  You could also write Scheme code instead.  ;-)
It's already in C++.
>> Also what are the args the REPL says you can supply to (make-module) ?.
> ‘make-module’ takes one optional argument, which is the expected number
> of bindings in the module (it’s a hint so that the underlying hash table
> has the right size from the start.)
Since posting this I managed to track down the V1.8.7 ice-9/boot-9.scm,
where this is declared.

It looks like there are three optional parameters, and the code is
trying to do a home-grown version of (ice-9 optargs) to default the
first parameter of missing to be 31, and then process two others, an
optional list of modules to be added to the new module's uses list and
an optional initialization thunk to be called.

It's as it it's trying to do
(define*-public (make-module (#:optional (size=31)
  #:optional (uses-list='()) #:optional (init-thunk='()))

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 ,  );

I suppose I could try a bit more noodling around in the REPL.



reply via email to

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