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: Transition from guile-ii to 1.2


Mark Galassi wrote:
> 
> I can answer some of your questions, but not all.
> 
>     Rob> 2) To do a sort, I used something like:
> 
>     >> (require 'sort)
>     >> (sort! '("hello" "there" "testing" "one") string<?)
> 
> slib used to be bundled with Guile, but it is not anymore.  To use
> slib you must install slib separately (I install it in
> $(prefix)/share/guile/site/slib), and then go through the module
> system, which you can currently do with
> 
> (use-modules (ice-9 slib))
> 
> after which your (sort! '("hello" "there" "testing" "one") string<?)
> should work (it does for me).

I found "slib2c0.tar.gz" and stuck it in
"~/guile-1.2/share/guile/site/slib" (I haven't "installed" guile yet). 
After a little digging, I set
SCHEME_LIBRARY_PATH=/usr/spi/grenoble/guile-1.2/share/guile/site/slib/
and
SCHEME_LOAD_PATH=/usr/spi/grenoble/guile-1.2:/usr/spi/grenoble/guile-1.2/share/guile/site
(possibly being supersticious).

Just running "(use-modules (ice-9 slib))" didn't work...
(no routine "identity")

I have done the following:

    > (use-modules (ice-9 slib))
    > (load "/usr/spi/grenoble/guile-1.2/ice-9/slib.scm")
    > (define home-vicinity
    >   (let ((home-path (getenv "HOME")))
    >       (lambda () home-path)))
    > (require 'sort)
    > (sort #(6 7 3 2 0) <)

and it seems to loop forever...  Any hints on the "correct" way to get
this going?  I cannot find any real mention of guile in the slib docs
and the only slib info I can find is in "slib.scm".

>     Rob> 4) I have some C++ code which writes to a scheme port.  I
>     Rob> used to use "gscm_fwrite" which would return the number of
>     Rob> chars written.  The only public routine I can find to do the
>     Rob> same thing is "scm_gen_write" which does not return the char
>     Rob> count.  Is there some other routine I should use?
> 
> How about writing your own wrapper which first gets the length, then
> prints it, and then returns the length?

I *could* do that, but my point was that the "write" routines are
supposed to return an exit code which indicates success or failure
(using a count of bytes written).  Since the port routines return this
info, but the only publically visible function (scm_gen_write) does not,
I cannot determine if the write succeeded.

Thanks for the other replies!

Oh, my question regarding registering a C++ dispatch routine....  I have
slightly changed my strategy.  Any comments on this approach?

>     // TODO: const cast                                                                    
>     char *cmdName = (char *)cmd->getName();                                                
>                                                                                            
>     SCM dispatch_proc = scm_make_subr( cmdName, scm_tc7_lsubr, (SCM (*)())dispatch );      
>     SCM cclo = scm_makcclo( dispatch_proc, 2 );                                            
>     DISPATCH_CCLO_CMD(cclo) = SCM_MAKINUM(((long)cmd) >> 2);                                      
>     SCM symbol = scm_sysintern( cmdName, cclo );                                           
> #ifdef DEBUG_EXTENSIONS                                                                    
>     if (SCM_REC_PROCNAMES_P)                                                               
>         scm_set_procedure_property_x(cclo, scm_i_name, SCM_CAR(symbol));                   
> #endif                                                                                     

The big difference is that now I create the "dispatch_proc" every time
and using the name of the C++ command (so that the debug backtraces look
okay) and then create the closure using the same name (so the internal
routine is inaccessible).

-rob

-- 
------------------------------------------------------------------------
Rob Engle                                      grenoble@spimageworks.com
Sony Pictures Imageworks                             voice: 310-840-8203
9050 West Washington Boulevard                         fax: 310-840-8567
Culver City, CA  90232
------------------------------------------------------------------------