This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Where should guile modules store meta data?
- To: guile@cygnus.com
- Subject: Where should guile modules store meta data?
- From: Jost Boekemeier <jostobfe@calvados.zrz.TU-Berlin.DE>
- Date: Wed, 2 Jun 1999 12:12:06 GMT
A module is a structure used to encapsulate related data and functions
with a restricted view from the outside. Typically, modules are used
to hide implementation details through a well-defined set of functions
called the interface. The module consists of two main parts: the
head, where you store the information what and how something should be
visible and the body, where you define your functions and data
structures.
In traditional languages like C these where two separate files. The
advantage is that you can publish the interface without showing how
things where implemented. The disadvantage is that you have to maintain
two separate files.
Modern languages like Java and Oberon do not use two separate files
but instead store the information what is visible the the world
inside the implementation file:
(* oberon *) // java
MODULE Tests; package test;
IMPORT Vectors;
import java.util.Vector;
TYPE Point* = POINTER TO PointDesc;
TYPE PointDesc* = RECORD public class Point {
versus
;;; *** scheme48 *** /* standard c */
1. INTERFACE from FILE
misc/packages.scm:
------------ packages.scm ------ ----- weaks.h -----
[...]
Procedure annotations #include "libguile/__scm.h"
(define-structure annotations #define SCM_WVECTP(x) ...
(export annotate-procedure
procedure-annotation) extern SCM scm_make_weak_vector
(open scheme-level-1 assembler)
(files annotate))
---------- end of packages.scm --- ------- end of weaks.h -----
2. Definitions for annotate
in file misc/annotate
--------- annotate.scm -------- ------ weaks.c -----------
[...] #include "weaks.h"
(define annotate-procedure SCM
(lap annotate-procedure scm_make_weak_vector (k, fill)
[...] ....
(define procedure-annotation
[...]
-------- end of annotate.scm --- ----- end of weaks.c ----
With the new environment implementation we can have both. A module
system like scheme48's or a more modern module/package system that doesn't
split the module's declarations and definitions into two separate files.
My question is: Should meta data (information about what is visible
to the world, what package this module belongs to etc.) be stored
in a separate file or should this information be part of module itself?
How should guile's primary module interface look like?
1. We can put the information in the first line of each file as in:
-------------------------------------------------------------------
; this is the module `test-module' (part of the `package1' package)
; located in the subdirectory package1/
;
; the module's interface:
(module-define '(package1 test-module) '<imports> '<exports> <protects> <init>)
; the module's definitions:
(define ...)
2. Or we can have a separate config file in each directory:
-------------------------------------------------------------#
$ ls package1
config.scm test-module.scm
$ #the config module for package `package1'
$ cat config.scm
(module-define test-module.scm '<imports> '<exports> <protects> <inits>)
$ #the implementation of test-module (part of `packag1' package)
$ cat test-module.scm
(define ...)
Jost