guile-user
[Top][All Lists]
Advanced

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

Re: guile 1.4 module system


From: Alex Schroeder
Subject: Re: guile 1.4 module system
Date: Sun, 16 Sep 2001 20:54:24 +0200
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7

Thien-Thi Nguyen <address@hidden> writes:

> see Marius Vollmer's recent implementation of `runtime-use-modules' for
> a way to do this.

Where can I find that?

> there is indeed a relationship: module `(a b c)' is expected in file
> a/b/c.scm somewhere under `%load-path'.  see also `%load-extensions'.

Thanks, I finally built the lates Guile including documentation and I
love it.  :)

>    Remember that admin.scm will use two modules that export the same
>    names.  The question is therefore how will I access these?
>
> keep an eye out for the `:renamer' clause in the documentation.  another
> approach is to use generic functions.  (from my brief understanding of
> your situation, g.f. might actually be the better approach.)

Hm, I just read two pages on generic functions in Common Lisp and
that's not what I want because the arguments are always the same.  As
far as I understood generic functions, you can have various
definitions using the same function name but varying parameter types.

Let me try to restate the problem with some sample (untested) code.
As you can see in admin.scm below, I want to load the data file in
either case.  The function is always called "report" and the parameter
is always a string.  Using module 1, however, "report.scm" produces
plain text output; using module 2, "report.scm" produces XML output.

report.scm -- the data file
---------------------------

(report "Alex")

text.scm -- producing text output
---------------------------------

(define-module (text))
(define-public (report name)
  (display "My name is ")
  (display name)
  (newline))

xml.scm -- producing xml output
-------------------------------

(define-module (xml))
(define-public (report name)
  (display "<name>")
  (display name)
  (display "</name>")
  (newline))

admin.scm -- choosing the user interface
----------------------------------------

(define data-file "report.scm")
(case (list-ref 1 (command-line))
  (("text")
   (use-modules ((text)))
   (load data-file))
  (("xml")
   (use-modules ((xml)))
   (load data-file)))

Alex.
-- 
http://www.geocities.com/kensanata/
Coffee should be black as hell, strong as death and sweet as love.
        -- Turkish proverb



reply via email to

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