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



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).

    Rob>    This no longer works and I cannot find *any* sort function
    Rob> in the guile-1.2 distribution.  Is there some other place I
    Rob> should be going for "extras" like this?

Most of them will be in the slib interface.

    Rob> 3) I am using guile as an embedded language for a C++ program
    Rob> that has its own notion of "commands".  I have a central
    Rob> dispatch routine for all entry from scheme into my commands.
    Rob> The previous engineer had done a *lot* of tweaking of
    Rob> guile-ii to make this work.

    Rob> [scm_make_subr discussions and all]

You could take a look at Jim Blandy's essay on data representation,
which will eventually end up in the reference manual.  Right now it is
in the separate guile-doc package on ftp://ftp.red-bean.com/pub/guile/
in the file sources/data-rep.texi

In it you will find some discussion of scm_make_gsubr() and so forth.

Jim might also answer you in more detail.

    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?

    Rob> 5) When in interactive mode, "(let ((x 3)) (write foopy))"
    Rob> gives: [...]

I think this is pretty much the same as your first question.  I think
Jim or Mikael will get back to you on it.

    Rob> 6) How do I expand a procedure?  In guile-ii I could just
    Rob> type the procedure name and it would give a (somewhat)
    Rob> readable representation of the procedure.  In guile-1.2, I
    Rob> just get "#<procedure blah args>".

The options interface allows you to do that.  Here's an example
session in which I dick around with the print options:

<3 papageno->rosalia> guile
guile> (define (f x) (* x x))
guile> (print-options 'full)
source          no      Print closures with source.
closure-hook    #f      Hook for printing closures.
guile> f
#<procedure f (x)>
guile> (print-enable 'source)
(source closure-hook #f)
guile> f
#<procedure f (x) (* x x)>
guile> 

    Rob> 7) As an example, the procedure "debug-enable" doesn't
    Rob> actually show up in the main symbol table.  However, it is
    Rob> defined.  Is this an example of the new module system?  Can
    Rob> someone point me to some docs on how the module system works?

I think it's some clever macro stuff Mikael did when he implemented
the options interface.  Current snapshots of guile-doc have my attempt
at documenting the options interface, but I think it will need another
pass.

    Rob> 1) "#f" used to mean empty list (in addition to "()").

That was kind of a silly feature for Scheme, and Jim Blandy and
Richard Stallman have come up with a way of keeping Guile's Scheme
"pure" while still providing an emacs lisp infrastructure.  I forget
the details, but Jim might be able to send you his white paper on the
subject.

    Rob> 2) "defined?" used to be a macro so that (defined? goober)
    Rob> was legit.  Now, one must use (defined? 'goober)

You might want to keep your eyes open for how the dust will settle on
that issue.  I remember discussion and I don't remember the result.

    Rob> 3) "print" routine is gone... have to use (write obj) and
    Rob> (newline) instead

"print" is provided in SLIB's YASOS, but I think it's got stuff you
don't want.  It requires a port argument, and

(use-modules (ice-9 slib))
(require 'yasos)
(define (f x) (* x x))
(print f (current-output-port))

is clumsy and gives a funky #t right after the object gets printed.

I guess (define (myprint obj) (begin (write obj) (newline))) is what
you need.  Or you could call it like pascal's writeln :-)