[gambit-list] R7RS libraries and udem-dlteam/libs

Amirouche Boubekki amirouche.boubekki at gmail.com
Sun Nov 3 10:28:20 EST 2019


Le sam. 2 nov. 2019 à 15:20, Marc Feeley <feeley at iro.umontreal.ca> a écrit :
>
>
> > On Nov 2, 2019, at 3:39 AM, Amirouche Boubekki <amirouche.boubekki at gmail.com> wrote:
> >
> > Hello all!
> >
> > Can some brush me up about the R7RS libraries effort in Gambit?
> >
> > I stumbled upon https://github.com/udem-dlteam/libs/ but:
>
> That repo hosts the WIP for creating libraries to be added to the libraries in the Gambit system.  At the moment it is mainly for porting existing SRFIs.

It is not clear how yet-another-repository will help.

> You are welcome to contribute!

I plan to do so.

>
> >
> > A) There is no tests
>
> It is important for any module to have tests, and the current absence of tests is something to fix.  Gambit now has a testing module called _test that is convenient for such tests.  Each module “foo” should have a submodule “test” that contains the tests.  This is only a convention… there’s nothing specific about that structure that the Gambit system knows about.  But it makes for easy testing by adding “/test” at the end of a module reference.
>
> Here’s an example for the github.com/gambit/hello library:
>
> % gsi github.com/gambit/hello/test at 2.1
> % echo $?
> 0
> % cat ~/.gambit_userlib/github.com/gambit/hello/@2.1/test.scm
> (define-library (github.com/gambit/hello test)
>
>   (import (.. hello)) ;; relative import (preserves the version)
>   (import (_test))    ;; for check-equal? and check-tail-exn
>   (import (gambit))   ;; for lambda, with-output-to-string, and
>                       ;; wrong-number-of-arguments-exception?
>
>   (begin
>
>     (check-equal? (with-output-to-string (lambda () (hi "you")))
>                   "hello you!\n")
>
>     (check-equal? (with-output-to-string (lambda () (salut "hi")))
>                   "bonjour hi!\n")
>
>     (check-tail-exn wrong-number-of-arguments-exception?
>                     (lambda () (hi)))
>
>     (check-tail-exn wrong-number-of-arguments-exception?
>                     (lambda () (hi "foo" "bar")))))
>
>

Thanks!

> >
> > B) There is no doc
>
> I’m open to suggestions…
>

I have an idea. I will raise the issue later on schemedoc. What we
could do, is have a common documentation that can be "translated" into
each implementation using gettext.

> >
> > C) The layout of the repository is as far as I can tell:
> >
> >  libs/srfi/1/1.sld
> >
> > That would me that srfi 1 is importable with:
> >
> >  (import (srfi 1 1))
> >
> > which looks odd. Maybe I misunderstood something.
>
> There are two possible mappings from a module reference to a file system path.  The module search algorithm will take the module reference “foo/bar” and look for the following files in the module search order (the list of directories searched by default are ~~lib and ~~userlib):
>
>     foo/bar/bar.sld     (or .scm or .six)
>     foo/bar.sld         (or .scm or .six)
>
> This allows using a nested layout (with a specific directory for module foo/bar) and a flat layout (where foo directly contains the files foo.sld, bar.sld and possibly other submodules of foo).
>
> Sometimes a nested layout is good, but sometimes it is overkill (many directories containing a single file so the flat layout can be used if the programmer thinks this is appropriate).
>
> >
> > D) There is not (scheme fu) libraries
>
> These are part of Gambit now.  Try:
>
> % gsi -e '(let () (namespace ("void#") ("" import)) (display "hello!\n"))'
> *** ERROR IN (string)@1.44 -- Unbound variable: void#display
> % gsi -e '(let () (namespace ("void#") ("" import)) (import (scheme write)) (display "hello!\n"))'
> hello!
> % cat lib/scheme/write/write.sld
> (define-library (scheme write)
>
>   (namespace "")
>
>   (export
>
> display
> write
> write-shared
> write-simple
>
> ))
>
> >
> > E) Can someone add a dummy test for a dummy library so that I can see
> > how to run recent gambit with R7RS? Here is an example of such thing:
> > https://github.com/amirouche/arew-scheme/blob/master/src/tests-tests.scm
>
> See the github.com/gambit/hello example.
>

Thanks!

> >
> > F) While I am at it, does gambit new module system support
> > introspection or reflection?
>
> Depends what you mean… Gambit has hooks for… *everything*.

I will do with what I know for the time being.




More information about the Gambit-list mailing list