[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jan 5 00:21:02 2001 
Subject:Re: Modifying the CL subsystem. Packages. 
From:Aaron Sloman See text for reply address 
Volume-ID:1010105.01 

[To reply replace "Aaron.Sloman.XX" with "A.Sloman"]


Marco Antoniotti <marcoxa@cs.nyu.edu> writes:

> Date: 04 Jan 2001 10:22:42 -0500
> Organization: New York University
>
>
> Hi
>
> I am slowly adding CL ANSI features to the CL subsystem.

Sounds good.

> I need to add the :documentation slot to the package structure.
> However, I still cannot find my ways around the directory structure.
> The file 'defpackage.lsp' has a reference to the function
> SYS:MAKE-PACKAGE, but I cannot locate (I am very lazy :) ) the source
> of the record/struct that implements the PACKAGE stuff.  I assume it
> must be somewhere in the POP code, but where?

The lisp function MAKE-PACKAGE is defined in

    src/packages.lsp

It invokes

	sys:make-package

In the file src/exports there is this declaration, which I found using
grep:

    @SYS:MAKE-PACKAGE,               make_package,                    []

This presumably declares the lisp identifier SYS:MAKE-PACKAGE
to be a synonym for the pop-11 identifier make_package, the name of a
procedure.

This procedure is defined in one of the core poplog system files
in $popsrc (= $usepop/pop/src/ )

    $popsrc/lispcore.p

This file is built into the core poplog system so if it is changed it
will be necessary to recompile poplog.

Looking at the definition of make_package:

    define make_package(names, used, size) -> pkg;

I find that after doing some checking it invokes Newpackage(names, size)

Te procedure Newpackage uses the package_key structure to create a
record which is an instance of the package class. The package has fields
for size, names, shadows, uses and users.

The package_key structure defined in the same file lispcore.p
by means of a structure definition using syntax (for syspop11) with
which I am not familiar. I don't know whether this syntax ever got
documented properly. It is used by the pop-11 system compiler.
This seems to define a pop-11 record class key, called package_key,
which will specify the properties of all the instances of the
record class package:

constant

	package_key = struct KEY_R =>> {%
		_NULL,                      ;;; K_GC_RELOC
		key_key,                    ;;; KEY
		_:M_K_SPECIAL_RECORD
			_biset _:M_K_WRITEABLE, ;;; K_FLAGS
		_:GCTYPE_FULLREC,			;;; K_GC_TYPE
		$-Sys$-Record_getsize,      ;;; K_GET_SIZE

		"package",                  ;;; K_DATAWORD
		false,                      ;;; K_SPEC
		false,                      ;;; K_RECOGNISER
		WREF $-Sys$-Exec_nonpd,     ;;; K_APPLY
		nonop ==,                   ;;; K_SYS_EQUALS
		WREF nonop ==,              ;;; K_EQUALS
		Lisp_obj_print,             ;;; K_SYS_PRINT
		WREF Lisp_obj_print,        ;;; K_PRINT
		WREF Hash_package,          ;;; K_HASH

		_:NUMTYPE_NON_NUMBER,       ;;; K_NUMBER_TYPE
		_:PROLOG_TYPE_OTHER,        ;;; K_PLOG_TYPE
		_:EXTERN_TYPE_NORMAL,       ;;; K_EXTERN_TYPE
		_0,                         ;;; K_SPARE_BYTE

		@@(struct PACKAGE)++,       ;;; K_RECSIZE_R
		false,                      ;;; K_CONS_R
		false,                      ;;; K_DEST_R
		false,                      ;;; K_ACCESS_R
		%},

This bit

		@@(struct PACKAGE)++,       ;;; K_RECSIZE_R

refers to an earlier structure definition in the same file:

    struct PACKAGE
      { full    PKG_VECTOR,
			    KEY,
    >->         PKG_NAMES,
			    PKG_SHADOWS,
			    PKG_USES,
			    PKG_USERS;
      };


It looks as if the actual instances of the package record class will
have these five fields PKG_VECTOR, PKG_NAMES, PKG_SHADOWS, PKG_USES,
PKG_USERS, in addition to having a pointer to the key (package key).

So if you want a package record to have an additional field it will
have to be done by extending this PACKAGE structure definition,
eg with field PKG_DOCUMENTATION, and then following through all the
things that need to be done to access the extra field from lisp.

I fear that's going to be a non-trivial task for someone who is not used
to pop-11 and especially its system dialect used in the files in
$popsys.

If you change the file lispcore.p you'll need to recompile it using
pgcomp, then archive it using pglibr, then rebuild the system using
pglink, as explained in
    http://www.cs.bham.ac.uk/research/poplog/sysdoc/rebuilding

I don't know if I have given you enough information to get started, or
whether it's going to depend on someone who knows more about the system.

If you can work out what changes you want to make, then a request to
comp.lang.pop on how to rebuild the system thereafter will probably be
answered.

I don't know if John Williams is reading this stuff. If he is I
hope he'll correct any errors in what I've written.

Good luck.

Aaron