This is the mail archive of the guile@sourceware.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]

New environment/module patches



The patches will be available tomorrow (1999/11/26, 4am, CET)
                              --------

--> http://www.user.tu-berlin.de/~jostobfe/


From the readme:

-*- text -*-

New features:

* All exported symbols are now marked read-only.  Use `(export (symbol mutable-location))' to
  export a writeable cell.  (the previous behaviour was a bug :>)

* The semantics of the module's public- and export-environment have changed.  The module's
  public-environment now exports symbols from the module's export-environment which in turn
  exports symbols from the module's eval-environment.  Which means:

  (module (my module)
          (open (ice-9 root))
	  (export a b c internal)
          (public a b c))

   makes the symbols `a', `b' and `c' available to all modules while `internal' is hidden 
   within the package `my'.

* Every module must have an export and public environment.  But if these environments don't specify
  a export signature, *all* symbols are exported:

  (module (my module)
          (open (ice-9 root))
          (public))
    
   makes *all* symbols available to all modules of the package `my' and *no* symbols available 
   to all other modules.

* When you leave a module `(my module)' (with C-d for example) you can start a new repl by using 
  (go (my module)).

* New macro: (module-close <modname>) *marks* a module as beeing closed.  This module will
  disappear as soon as it is no longer referenced:

     user/guile> (define-module (my test))   
     my/test> (define a 12)
     my/test> a
     12
     my/test> (module-close (my test))
     my/test> a
     12
     my/test> (define-module (my test))
     my/test> a
     ERROR: Unbound variable: a
     ABORT: (misc-error)



* New functions:
   (environment-symbol-property <env> <sym> <prop>)
   (environment-set-symbol-property! <env> <sym> <prop> <val>)
   (environment-remove-symbol-property! <env> <sym> <prop>)

* New macros:
   symbol-property, symbol-set-symbol-property, remove-symbol-property

  symbol-properties of a given symbol are also available in environments (or modules) that
  import the symbol but *not* in unrelated environments (or modules).

  A silly example:
     user/guile> (define-module (company people))
     company/people> (define egon 'person)
     company/people> (set-symbol-property!  'egon 'revenue 100000) 
     company/people> (export egon)
     company/people> (define-module (company management) :use-module (company people))
     company/management> egon
     person
     company/management> (symbol-property 'egon 'revenue)
     (revenue . 100000)
     company/management> (define egon egon) ;; a local "copy" of egon :>
     company/management> (set-symbol-property! 'egon 'comment 'too-much)
     company/management> (export egon)
     company/management> (define-module (company registry))           
     company/registry> (module-open (ice-9 root) (company people))
     company/registry> egon
     person
     company/registry> (symbol-property 'egon 'comment)
     #f
     company/registry> (module-open (ice-9 root) (company management))
     company/registry> (symbol-property 'egon 'comment)
     (comment . too-much)


* (the-environment) returns the current *top-level* environment. 

* the variable (the-module) has been replaced by a macro which maps (the-environment) to
  (the-module):

    (define the-module
      (procedure->syntax
       (lambda (x env)
         (hashq-ref environment-hash (car (reverse env) )))))

  You can access the module signature for any eval-environment as follows:

     (define some-module (hashq-ref environment-hash eval-environment))

  or, if you know the name of the module:

     (environment-ref module-environment <module-name>) 

  In general the module-environment maps (external) module names to module signatures 
  which in turn have information about the state of the module, while the environment-hash 
  maps eval-environments to module signatures.



What is still NOT implemented:  

* feature renaming
* support for lexical environments
* goops support (module signature is a goops class)
* define-public is implemented but currently broken


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]