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

question on byte specifier format



I'm attempting to port code originally written for the Symbolics and TI
Lisp environments to AllegroCL-4.0 and am having problems compiling a
function that contains a call to a macro whos expansion contains the value
of a constant (defined with 'defconstant' and evaluated in the macro via
a backquote and comma) whos value is a byte specifier (created using 'byte').
The compiler believes the byte specifier is a function call and complains.

In Cltl-2, section 12.8 states
	"The representation of a byte specifier is implementation-dependent;
	 in particular, it may or may not be a number"
and section 5.3.2 states
	"However, if the compiler chooses to replace references to the name
	 of the constant by the value of the constant in code to be compiled,
	 .... the compiler may freely make copies of numbers by must exercise
	 care when the value is a list."

It appears ACL-4.0 uses a list.  Since I'm not sure where this code may
migrate to, would like to insert read-time conditionals and want to know
whether to use ':allegro' or ':allegro-v4.0',

   1) Does ACL in fact use a list notation for a byte specifer?
   2) If so, is this format the result of the 'implemenation-dependent'
      aspect as mentioned in Cltl-2 (section 12.8)?
   3) If so, is this specific to ACL-4.0 or to all Allegro versions?

Thanks in advance.

-- Tony Guzzi
   Taylor L. Booth Center for Computer Applications and Research

 Internet:		     |	U.S. Mail:
	tony@brc.uconn.edu   |		University of Connecticut
			     |		Rm 54, U-31, Booth Research Center
			     |		233 Glenbrook Road
			     |		Storrs, CT  06269-4031

###########################################################################
###  The following is a file listing and transcript of the compilation  ###
###########################################################################
#>>> File listing (abbreviated)

;;;-----------------------------------------------------------------------------
;;;  SETF method for LDB-TEST
;;;
;;;  This setf method for ldb-test allows for setf'ing truth values for forms
;;;  such as (variable-independent-p var).  This method was adapted from the
;;;  example on page 106 of "Common Lisp the Language" by Guy Steele Jr.
;;;
;;;  Note:  The Symbolics and TI Lisp environments defines a similar setf
;;;         method for ldb-test, but since it is not part of the language
;;;         definition, we include this definition so that this will work on
;;;         non-Symbolics systems.
;;;-----------------------------------------------------------------------------

(define-setf-method ldb-test (bytespec word)
  (multiple-value-bind (word-temps word-vals word-stores word-store-form word-access-form)
      (get-setf-method word)                ; get setf method for int.
    (let ((btemp (gensym))                  ; temp var for bytespec.
          (store (gensym))                  ; temp var for truth val to store.
          (vtemp (gensym)))                 ; temp var new byte value.
      (values (cons btemp word-temps)       ; temporary variables.
              (cons bytespec word-vals)     ; value forms.
              (list store)                  ; store variables.
              `(let* ((,vtemp (if ,store 1 0))
                      (,(first word-stores)
			      (dpb ,vtemp ,btemp ,word-access-form)))
                 ,word-store-form)          ; Storing form.
              `(ldb-test ,btemp ,word-access-form)))))  ; Accessing form.

;;;-----------------------------------------------------------------------------
;;;  Structure:  VARIABLE
;;;-----------------------------------------------------------------------------

(defstruct (VARIABLE (:print-function variable-printer))
  name                       ; print-name
  (flags 0)                  ; Flags: see below
  (modes nil)                ; alist of (qmag . list of CONSTRAINTs)
)

(eval-when (compile load eval)
   (defconstant *NO-NEW-LANDMARKS* (byte 1 3)   "bit 3 of VARIABLE flags")
   (defconstant *DISCRETE*         (byte 1 4)   "bit 4 of VARIABLE flags")
) ;;; end 'eval-when'

(defmacro VARIABLE-NO-NEW-LANDMARKS-P (var)
  `(ldb-test ,*NO-NEW-LANDMARKS* (variable-flags ,var)))

(defmacro VARIABLE-DISCRETE-P (var)
  `(ldb-test ,*DISCRETE* (variable-flags ,var)))


(defun VARIABLE-PRINTER (variable stream ignore)
  (declare (special *detailed-printing*) (ignore ignore))
  (if *detailed-printing*
      (format stream "#<Var ~(~a~)>" (variable-name variable))
      (format stream "~a" (variable-name variable))))

;;;-----------------------------------------------------------------------------

(defun SET-VARIABLE-SWITCHES (variable qde discrete)
  (when discrete
    (setf (variable-discrete-p variable) t))
  (when (member (variable-name variable)
		(alookup 'no-new-landmarks (qde-other qde)))
    (setf (variable-no-new-landmarks-p variable) t)))


###########################################################################
#>>> Compilation  ('cl4.0p' ==> AllegroCL v4.0.1 w/ patches [up to patch91])

SunOS Release 4.1.1 (SPARC.SERVER_IPC) #2: Tue Oct 29 15:12:34 EST 1991

1 sparc1.brc>>> cl4.0p
Allegro CL 4.0.1 [Sun4] (2/8/91)
Copyright (C) 1985-1991, Franz Inc., Berkeley, CA, USA
Starting execution of '~/.clinit.cl' file.

Ignoring case of package names.
Loading alternate 'loop' definition from ACL dist.
Setting top-level parameters.

Done executing '~/.clinit.cl' file.
<cl>:cf setft.lisp

; --- Compiling file /home/user2/tonyg/testdir/setft.lisp ---
; Compiling (EXCL::SETF-METHOD-EXPANDER LDB-TEST)
; Compiling MAKE-VARIABLE
; Compiling VARIABLE-P
; Compiling VARIABLE-NO-NEW-LANDMARKS-P
; Compiling VARIABLE-DISCRETE-P
; Compiling VARIABLE-PRINTER
; Compiling SET-VARIABLE-SWITCHES
Error: Function position must contain a symbol or lambda expression: 1
Error detected when processing
       (1 . 4)
inside (SETF (VARIABLE-DISCRETE-P VARIABLE) T)
inside (WHEN DISCRETE (SETF (VARIABLE-DISCRETE-P VARIABLE) T))
inside (BLOCK SET-VARIABLE-SWITCHES
         (WHEN DISCRETE (SETF # T))
         (WHEN (MEMBER # #) (SETF # T)))
inside (PROGN (BLOCK SET-VARIABLE-SWITCHES
                (WHEN DISCRETE #)
                (WHEN # #)))

Restart actions (select using :continue):
 0: retry the compilation of #p"/home/user2/tonyg/testdir/setft.lisp"
[1] <cl> :pop
<cl> EOF
Really exit lisp [n]? y
; Exiting Lisp
2 sparc1.brc>>>