This is the new-op Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Sep 15 06:12:18 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
new-op
The NEW-OP System.
A (not so) new NEW operator that subsumes all the ’make-...’ functions and methods of Common Lisp.
Marco Antoniotti
BSD
new-op-pkg.lisp
(file).
new-op.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
new-op/new-op.lisp
new-op-pkg.lisp
(file).
new-op
(system).
*coerce-array-elements-p*
(special variable).
*coerce-numbers-p*
(special variable).
new
(generic function).
newq
(macro).
register-structure-constructor
(function).
type-cons
(generic function).
*default-dummy-hash-table*
(special variable).
*structure-constructors*
(special variable).
check-numeric-interval-element
(function).
check-optional-args-number
(macro).
compute-data-dimensions
(function).
compute-dimensions
(function).
copy-hash-table
(function).
find-structure-constructor
(function).
interval-type-cons
(generic function).
make-rational
(function).
numeric-real-types
(type).
type-check
(macro).
Packages are listed by definition order.
it.unimib.disco.ma.cl.ext.tac.new-op
common-lisp.extensions.type-and-classes.new-op
cl.ext.tac.new-op
new-op
common-lisp
.
*coerce-array-elements-p*
(special variable).
*coerce-numbers-p*
(special variable).
new
(generic function).
newq
(macro).
register-structure-constructor
(function).
type-cons
(generic function).
*default-dummy-hash-table*
(special variable).
*structure-constructors*
(special variable).
check-numeric-interval-element
(function).
check-optional-args-number
(macro).
compute-data-dimensions
(function).
compute-dimensions
(function).
copy-hash-table
(function).
find-structure-constructor
(function).
interval-type-cons
(generic function).
make-rational
(function).
numeric-real-types
(type).
type-check
(macro).
Definitions are sorted by export status, category, package, and then by lexicographic order.
If true array initial elements are coerced to the expected type.
The default is NIL.
If true numbers are coerced to the expected type (in number constructors).
The default is NIL.
The NEWQ macro is a convenience syntactic shortcut to the NEW function.
The macro expands into a call to NEW without evaluating the first argument.
Registers CONSTRUCTOR for structure class SC.
The CONSTRUCTOR will then be available to NEW whenever a SC needs to be created.
Generic ’construction’ function.
The NEW generic function is a single entry point for MAKE-INSTANCE, DEFSTRUCT and other constructors, e.g., for HASH-TABLEs and ARRAYs.
Methods for NEW can be defined specialized for new classes. Structure classes need to register their constuctor; see REGISTER-STRUCTURE-CONSTRUCTOR. Compound type specifiers must be specialized by defining methods for TYPE-CONS.
(eql bit)
) &rest arguments) ¶(eql unsigned-byte)
) &rest arguments) ¶(eql signed-byte)
) &rest arguments) ¶cons
) &rest arguments) ¶CONS Method.
This is the method that handles the compound type specifiers. It
eventually calls TYPE-CONS, which is in charge of dealing with each
compound type specifier.
In order to inform the NEW operator of a new compound type specifier it is thus sufficient to define an appropriate TYPE-CONS method.
(eql it.unimib.disco.ma.cl.ext.tac.new-op::hash-set)
) &rest arguments) ¶HASH-SET Method.
A specialised method yielding a HASH-TABLE with BOOLEAN values. It
can be invoked in two forms.
<pre>
new ’HASH-SET
&optional SEQUENCE-SET
&rest HASH-TABLE-STANDARD-ARGS
&key &allow-other-keys
</pre>
or
<pre>
new ’HASH-SET
&rest HASH-TABLE-STANDARD-ARGS
&key &allow-other-keys
</pre>
I.e., it dispatches on the first of the ARGUMENTS to decide whether it
also has to ’fill’ the newly created hash table; in this last case, it
behaves as a ’copy’ constructor for the hash-table skeleton, and then
it substitutes the values or the resulting hash-table with T. If the
first of the ARGUMENTS is a hash-table, the keywords are ignored. If
it is a keyword then it is assumed that the call must resolve to a
simple call to MAKE-HASH-TABLE. Otherwise, <sequence-set> must be an
SEQUENCE of elements of the set.
The result is an hash table.
(eql #<structure-class common-lisp:hash-table>)
) &rest arguments) ¶HASH-TABLE Method.
The HASH-TABLE method admits a non-traditional syntax. It can be
invoked in two forms.
<pre>
new ’HASH-TABLE
&optional PAIRS
&rest HASH-TABLE-STANDARD-ARGS
&key &allow-other-keys
</pre>
or
<pre>
new ’HASH-TABLE
&rest HASH-TABLE-STANDARD-ARGS
&key &allow-other-keys
</pre>
I.e., it dispatches on the first of the ARGUMENTS to decide whether it
also has to ’fill’ the newly created hash table; in this last case, it
behaves as a ’copy’ constructor. If the first of the ARGUMENTS is a
hash-table, the keywords are ignored. If it is a keyword then it is
assumed that the call must resolve to a simple call to
MAKE-HASH-TABLE. Otherwise, <pairs> must be an A-LIST of pairs
<pre>
(key . value)
</pre>
which are then fed into the newly created hash-table.
The result is an hash table.
(eql #<built-in-class common-lisp:double-float>)
) &rest arguments) ¶(eql #<built-in-class common-lisp:single-float>)
) &rest arguments) ¶(eql #<built-in-class common-lisp:fixnum>)
) &rest arguments) ¶(eql #<built-in-class common-lisp:integer>)
) &rest arguments) ¶(eql #<built-in-class common-lisp:ratio>)
) &rest arguments) ¶(eql #<built-in-class common-lisp:rational>)
) &rest arguments) ¶(eql #<built-in-class common-lisp:float>)
) &rest arguments) ¶(eql #<built-in-class common-lisp:real>)
) &rest arguments) ¶(eql #<built-in-class common-lisp:complex>)
) &rest arguments) ¶COMPLEX Method.
The COMPLEX method applies the function COMPLEX to the arguments.
(eql #<built-in-class common-lisp:number>)
) &rest arguments) ¶NUMBER Method.
The NUMBER method just checks that the argument is a number and returns it.
(eql #<built-in-class common-lisp:pathname>)
) &rest arguments) ¶PATHNAME Method.
The PATHNAME method dispatches on the first element of ARGUMENTS. If
it is a KEYWORD, it assumes that MAKE-PATHNAME is to be called,
applied to all the ARGUMENTS.
Otherwise it checks whether the first of ARGUMENTS ia a STRING, a
STREAM or a PATHNAME, in which case is passes it to the function
PATHNAME.
(eql #<built-in-class common-lisp:symbol>)
) &rest arguments) ¶SYMBOL Method.
The SYMBOL method has the following syntax.
<pre>
new ’symbol S &optional (PACKAGE *PACKAGE*) COPY-PROPERTIES
</pre>
S can be a STRING or a SYMBOL. If it is a SYMBOL, S is first copied,
using COPY-SYMBOL and COPY-PROPERTIES (cfr., COPY-SYMBOL in the CL
Standard). If S is a STRING then MAKE-SYMBOL is initially called. If
PACKAGE is NIL then a fresh, uninterned symbol is returned, otherwise
the resulting symbol is IMPORTed in PACKAGE.
(eql #<built-in-class common-lisp:character>)
) &rest arguments) ¶CHARACTER Method.
Applies the function CHARACTER to the first of ARGUMENTS.
(eql #<built-in-class common-lisp:list>)
) &rest arguments) ¶LIST Method.
Applies the function VECTOR to the ARGUMENTS.
(eql #<built-in-class common-lisp:string>)
) &rest arguments) ¶STRING Method.
Applies the function STRING to the first of ARGUMENTS.
(eql #<built-in-class common-lisp:vector>)
) &rest arguments) ¶VECTOR Method.
Applies the function VECTOR to the ARGUMENTS.
(eql #<built-in-class common-lisp:array>)
) &rest arguments) ¶ARRAY Method.
Calls MAKE-ARRAY after having manipulated the ARGUMENTS.
The ’bare’ constructor for objects of ’type’ ARRAY actually behaves
as having the following simple syntax:
<pre>
new ’array &optional INITIAL-CONTENTS &rest MAKE-ARRAY-keywords
</pre>
I.e., the constructor figures out the dimensions of the
INITIAL-CONTENTS before dispatching to MAKE-ARRAY.
class
) &rest arguments) ¶CLASS Around Method.
This method helps dealing with some of the vagaries of the CL type system, e.g., COMPLEX and RATIONAL types with their relationship.
built-in-class
) &rest arguments) ¶BUILT-IN-CLASS Method.
Signals an ’undefined’ error. This method is a sink for the built-in classes which do not have a specialized method built with EQL.
structure-class
) &rest arguments) ¶STRUCTURE-CLASS Method.
Applies the constructor of the STRUCTURE-CLASS to the ARGUMENTS. The constructor must have been registered with REGISTER-STRUCTURE-CONSTRUCTOR to be applicable.
standard-class
) &rest arguments) ¶STANDARD-CLASS Method.
Applies MAKE-INSTANCE to the class and ARGUMENTS. This method is, to all effects, MAKE-INSTANCE in disguise.
symbol
) &rest arguments) ¶SYMBOL Method.
Dispatches on the class named by the argument.
The TYPE-CONS Generic Function.
TYPE-CONS is the entry point to specialize in order to handle compound
type specifiers. The only assumption is that a compound type
specifier is a list with a symbol as first element, as described in
Section 4.2.3 ’Type Specifiers’ of the ANSI CL Specification.
Each method dispatches on the TYPE-NAME, which is a symbol. SPEC is
the CDR of the full type specifier and ARGUMENTS is the list of
arguments passed to NEW.
TYPE-CONS is meant to be specialized but not called directly.
Examples:
;;; Suppose you had
(deftype matrix (n m &optional (base-type ’double-float))
‘(array ,base-type (,n ,m)))
;;; You may want to define something along these lines.
(defmethod type-cons ((what (eql ’matrix)) spec arguments)
(destructuring-bind (n m &optional (base-type ’double-float))
spec
(assert (and (<= 0 n (1- array-dimension-limit))
(<= 0 m (1- array-dimension-limit))))
(apply #’make-array (list n m)
:element-type base-type
arguments)))
(eql class)
) spec arguments) ¶(eql structure)
) spec arguments) ¶(eql hash-table)
) spec arguments) ¶The HASH-TABLE Method.
It constructs a HASH-TABLE by handling a ’type specifier’ with a
syntax that makes the following call the NEW possible:
<pre>
(new ’(hash-table &rest HT-KEYS
&key
(TEST #’eql)
(SIZE (hash-table-size *default-dummy-hash-table*))
(REHASH-SIZE (hash-table-rehash-size *default-dummy-hash-table*))
(REHASH-THRESHOLD (hash-table-rehash-threshold *default-dummy-hash-table*))
&allow-other-keys)
&rest arguments)
</pre>
The defaults for each of the keyword arguments are implementation dependent.
(eql mod)
) spec arguments) ¶(eql unsigned-byte)
) spec arguments) ¶(eql signed-byte)
) spec arguments) ¶symbol
) spec arguments) ¶(eql complex)
) spec arguments) ¶(eql array)
) spec arguments) ¶ARRAY Method.
It constructs an array after having manipulated SPEC and ARGUMENTS;
the overall effect is similar to the NEW ARRAY method.
The TYPE-CONS method allows NEW to use the following syntax:
<pre>
new ’(array &optional
(ELEMENT-TYPE T)
DIMENSION-SPEC
&rest MAKE-ARRAY-kwds-1
&key
&allow-other-keys)
&optional
INITIAL-CONTENTS
&rest MAKE-ARRAY-kwds-2
&key
&allow-other-keys
</pre>
I.e., the constructor figures out the dimensions of the
<initial-contents> before dispatching to MAKE-ARRAY. Further checks
are made to ensure that the shape of <initial-contents> (if supplied)
is acceptable.
MAKE-ARRAY-kwds-1 and MAKE-ARRAY-kwds-2 are the normal MAKE-ARRAY
parameters. The actual call to MAKE-ARRAY is eventually of the form:
<pre>
(apply ’make-array
COMPUTED-DIMENSIONS
(append
(and INITIAL-CONTENTS
(list :initial-contents INITIAL-CONTENTS))
MAKE-ARRAY-kwd-1
MAKE-ARRAY-kwd-2))
</pre>
Therefore, order among the MAKE-ARRAY keywords is important.
It should be noted that
<pre>
(array &optional (ELEMENT-TYPE T) DIMENSION-SPEC)
</pre>
is a valid, yet constrained, type specifier.
(eql vector)
) spec arguments) ¶Utility macro producing ASSERTs that check the number of arguments.
Checks that PLACE contains an object of type TYPE.
It works like CHECK-TYPE, but TYPE is evaluated. It also returns T if the check succeeds.
Computes the dimensions of DATA.
DATA is a sequence of nested sequences. RANK can be passed to limit the depth of the reconstruction; if NIL (the default) the dimensions are computed down to ’atoms’. ERROR-IF-UNEQUAL-P controls whether an error is signalled if the shape of DATA is ’ragged’. An error is also signalled if RANK is higher than the actual DATA rank.
Copies and HASH-TABLE.
This function is implementation dependent. The basic behavior provided here just copies an hash-table with the standard components.
Jump to: | C F G I M N R T |
---|
Jump to: | C F G I M N R T |
---|
Jump to: | *
S |
---|
Jump to: | *
S |
---|
Jump to: | F I N P S T |
---|
Jump to: | F I N P S T |
---|