mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-07 09:50:25 -08:00
Allow structures to have :TYPE (VECTOR BIT), (VECTOR CHARACTER), etc,
and make use of that sequence type instead of the general one (VECTOR T).
This commit is contained in:
parent
d243d6b091
commit
e70961b8cf
5 changed files with 24 additions and 8 deletions
|
|
@ -1414,6 +1414,15 @@ ECLS 0.9
|
|||
- In destructuring lambda lists, &WHOLE may be accompanied by a
|
||||
destructuring form.
|
||||
|
||||
- In DEF{CLASS,CONDITION}, arguments to the :INITFORM option, or to
|
||||
the :DEFAULT-INITARGS option, are now properly evaluated in the
|
||||
lexical environment corresponding to the DEF{CLASS,CONDITION} form.
|
||||
|
||||
- Structures may now have :TYPE (VECTOR BIT), (VECTOR CHARACTER),
|
||||
etc. That sequence type is used, rather than the general one
|
||||
(VECTOR T). (:TYPE option from slots is not used, though).
|
||||
|
||||
|
||||
TODO:
|
||||
=====
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@ cl_copy_structure(cl_object s)
|
|||
s = ecl_copy_structure(s);
|
||||
break;
|
||||
case t_cons:
|
||||
case t_string:
|
||||
case t_bitvector:
|
||||
case t_vector:
|
||||
s = cl_copy_seq(s);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1086,4 +1086,5 @@ type_of(#0)==t_bitvector"))
|
|||
count count-if count-if-not substitute substitute-if substitute-if-not
|
||||
nsubstitute nsubstitute-if nsubstitute-if-not find find-if find-if-not
|
||||
position position-if position-if-not remove-duplicates
|
||||
delete-duplicates mismatch search sort stable-sort merge))
|
||||
delete-duplicates mismatch search sort stable-sort merge
|
||||
si::closest-vector-type))
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@
|
|||
;; the slot is at the offset in the structure-body.
|
||||
(fset access-function #'(lambda (x)
|
||||
(sys:structure-ref x name offset))))
|
||||
((or (eq type 'VECTOR)
|
||||
(and (consp type)
|
||||
(eq (car type) 'VECTOR)))
|
||||
((subtypep type 'VECTOR)
|
||||
;; If TYPE is VECTOR or (VECTOR ... ), ELT is used.
|
||||
(fset access-function
|
||||
#'(lambda (x) (elt x offset))))
|
||||
|
|
@ -140,10 +138,14 @@
|
|||
(sys:make-structure ',name ,@slot-names)
|
||||
#+CLOS
|
||||
(sys:make-structure (find-class ',name) ,@slot-names)))
|
||||
((or (eq type 'VECTOR)
|
||||
(and (consp type) (eq (car type) 'vector)))
|
||||
((subtypep type '(VECTOR T))
|
||||
`(defun ,constructor ,keys
|
||||
(vector ,@slot-names)))
|
||||
((subtypep type 'VECTOR)
|
||||
`(defun ,constructor ,keys
|
||||
(vector ,@slot-names)))
|
||||
(make-array ',(list (length slot-names))
|
||||
:element-type ',(closest-vector-type type)
|
||||
:initial-contents (list ,@slot-names))))
|
||||
((eq type 'LIST)
|
||||
`(defun ,constructor ,keys
|
||||
(list ,@slot-names)))
|
||||
|
|
@ -371,6 +373,9 @@ as a STRUCTURE doc and can be retrieved by (documentation 'NAME 'structure)."
|
|||
(when (and type initial-offset)
|
||||
(setq offset (+ offset initial-offset)))
|
||||
(when (and type named)
|
||||
(unless (or (subtypep '(vector symbol) type)
|
||||
(subtypep type 'list))
|
||||
(error "Structure cannot have type ~S and be :NAMED." type))
|
||||
(setq name-offset offset)
|
||||
(setq offset (1+ offset)))
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
:datum NIL))
|
||||
|
||||
(defun closest-vector-type (type)
|
||||
(declare (si::c-local))
|
||||
(let (elt-type length name args)
|
||||
(if (atom type)
|
||||
(setq name type args nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue