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: A new module system for Guile



Hi,


> (module "hugo"
>  (define a 1)
>  (define* b 2))

Well a module is not a first class object. It is just -- a file with
an interface. 

Since all module systems for lisp/scheme (all module systems i know of
that is :>) were designed before the advent of the OO paradigm, they
not only meet the requirements for a module/package system but also
support OO methods. Wade for example was able to create a full
featured OO system based on Guile modules. 

Bertrand Meyer [1] showed, that when using classes as the structuring form,
there is no need for modules except for bundling. 

Let me explain this by using two examples taken from the mz-scheme docu:

  (define f1@
     (unit
       (import) (export x)
       (define x (current-seconds))
       (display x) (newline) x))

This a *module*. A simple collection of definitions (top-level bindings).

BUT:

  (define f2@
     (let ([current-date current-seconds])
       (unit
         (import) (export x)
         (define x (current-date))
         (display x) (newline) x)))

This is a *class* evaluating to an object that prints the current date.

The requirements for a Guile module system where posted on this list
two years ago. The Guile module system should meet these requirements
but it should not go further. Guile will have an object system but it
is not neccesary to implement the object system twice.

On http://www.math.tau.ac.il/~guy/Oberon/bib-full.html#LanguageBooks
you find the reference to a paper that explains that a module and a class
are two differend kinds of animals:
    "Import is Not Inheritance - Why We Need Both: Modules and Classes" 
-> http://sky.fit.qut.edu.au/~szypersk/pub/ECOOP92.ps.gz



> Can modules be nested?

No. Classes can be nested.


> (foo (module* "hugo"))
> (foo (module* "walter"))
> (foo 0)  ; this is an error, but where?

If `0' is a bound to an obarray, `p' will be looked up there. The new
systax is `(module-ref <module> <sym>)' btw. :)


> Oh, here's the difference between module and module*.

module* can be thought of as a "module declaration". It simply says
"there is a module named `name' somewhere, get me its obarray."


Jost

@Book{Meyer97,
  author =       "B. Meyer",
  title =    "Object-Oriented Software Construction",
  year =         "1997",
  publisher =    "Prentice Hall",
  keywords =     "Eiffel,OOSC",
  address =      "New Jersey",
  ISBN =         "0-13-629155-4",
  edition =      2
}