The structure-ext Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The structure-ext Reference Manual

This is the structure-ext Reference Manual, version 0.0.3, generated automatically by Declt version 3.0 "Montgomery Scott" on Fri Jun 26 12:18:59 2020 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Systems

The main system appears first, followed by any subsystem dependency.


Next: , Previous: , Up: Systems   [Contents][Index]

1.1 structure-ext

Author

Shinichi Sato

License

MIT

Description

Tiny structure extensions

Version

0.0.3

Dependencies
Source

structure-ext.asd (file)

Component

package.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

1.2 structure-ext.left-arrow-accessors

Author

Shinichi Sato

License

MIT

Description

Slot accessor alias maker.

Long Description

# STRUCTURE-EXT.LEFT-ARROW-ACCESSORS 0.0.6

## introduction
Any language has direction.
In this context, "direction" means order of explain.
For example, English has "from center to around" direction, and Japanese has "from around to center" direction.

E.g. person name.
In English notation, my name is written as ’Shinichi Sato’.
Shinichi is first name (of course center), and Sato is family name (of course around).
But in Japanese notation, my name is written as "佐藤 真一".
"佐藤" equals "Sato", and "真一" equals "Shinichi".

Also day unit.
In English notation, its written "Day Month Year".
It aims from small unit to bigger unit.
But in Japanese notation, its written "年月日".
"年" equals "year", "月" equals "month", and "日" equals "Day".
It aims from big unit to smaller unit.

Also address notations.
In English notation, its written from small place like town to huge place like prefecture, state, etc...
But in Japanese notation, its written from huge place like prefecture to small place like town, street etc...

Of course each language has inversion though.

Also programming language is one kind of language.
In such context, we can refer center as "return value", and around as "algorithm".
Roughly, we can say imperative language has Japanese style "from around to center" direction, and functional language has English style "from center to around" direction.

## Current lisp world
In lisp comunity, functional programming style is recommended.
Language is carefully designed to be able to write functional style easily.
For example, LET’s binding is designed "from center to around"(var is center(It is what we want.), and init form is around.), METHOD’s specializer is designed so too, WITH-SLOTS’s alias is same, etc...

## Issues
But there is few "from around to center" rule in CL.
It is slot accessor or slot accessor style function name like CHAR-CODE.

## Proposal
Using left arrow instead of hyphen is proposed.
Do you think which code is easy to understand?

“‘lisp
(code-char n)
(char<=code n)
“‘
I bet it is almost same.
There is just small differences only.
But in many cases, we don’t write such low level code as toplevel.
Usually we nests it.
So how below?

“‘lisp
(defun example1 (symbol)
(let ((name (package-name (symbol-pakcage symbol))))
...))
(defun example2 (symbol)
(let ((name (name<=package (package<=symbol symbol))))
...))
“‘
In former case, relational part appears alternately.
While reading code from left to right, the stack in your brain acting violently like seesaw but later case.

There is no probrem with class, because we can specify arbitraly name as readers/writers/accessors, but structure.

## Usage

“‘lisp
(defstruct foo bar)
(DEFINE-LEFT-ARROW-ACCESSORS foo bar)
(bar<=foo (make-foo :bar 0))
=> 0
“‘

## From developer

* Product’s goal - already?
* License - MIT
### Tested
* SBCL/2.0.2
* CCL/1.12
* CLISP/2.49
* ECL/20.4.24

Version

0.0.7

Dependency

resignal-bind

Source

structure-ext.left-arrow-accessors.asd (file)

Component

left-arrow-accessors.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

1.3 structure-ext.make-instance

Author

Shinichi Sato

License

MIT

Description

Method make-instance for construct structure.

Version

0.0.6

Dependency

closer-mop

Source

structure-ext.make-instance.asd (file)

Component

make-instance.lisp (file)


Previous: , Up: Systems   [Contents][Index]

1.4 structure-ext.as-class

Author

Shinichi Sato

License

MIT

Description

Defstruct as defclass

Long Description

# STRUCTURE-EXT.AS-CLASS 0.0.6

## Current lisp world
Common Lisp has strong structure and class.

## Issues
In Common Lisp comunity, subject ’structure vs class’ is issued sometimes.

Only structure can do is nothing.
Only class can do is Multiple inheritance.

NOTE - Here, we ignores the thing which can not do but there is a way.
E.g. class is unreadable, but we can write reader macro.
E.g. structure does not have shared slot, but we can emulate it with symbol-plist.

So roughly, we can say ’if you need multiple inheritance, use class. otherwise structure. Because structure is fast.’

“‘Lisp
(defstruct foo slot)
(defclass bar () ((slot :initarg :slot :accessor bar-slot)))

;; constructor
(time (dotimes (x 1000) (make-foo :slot 0)))
=> 299,098 processor cycles
16,376 bytes consed
(time (dotimes (x 1000) (make-instance ’bar :slot 0)))
=> 19,777,048 processor cycles
187,400 bytes consed
;; 66 times faster, 11.5 times less consed.

;; accessor
(let ((s (make-foo :slot 0)))
(time (dotimes (x 1000) (foo-slot s))))
=> 26,771 processor cycles
(let ((c (make-instance ’bar :slot 0)))
(time (dotimes (x 1000) (bar-slot c))))
=> 143,488 processor cycles
;; 5.3 times faster.
“‘

## Proposal
DEFSTRUCT\* is almost same syntax with CL:DEFSTRUCT, but expanded into DEFCLASS and DEFMETHOD forms.
At first, start to write your application with CL:DEFSTRUCT.
If you need multiple inheritance, change CL:DEFSTRUCT to DEFSTRUCT\*, and add super class as :include option. DEFSTRUCT\* can accept multiple :include options.

## Constraints
### Invalid options
Option :type, :named, and :initial-offset are invalid in DEFSTRUCT\*

### Uncompleteness of copier
The copy function which is made by DEFSTRUCT\* has some constraints.

* Any slots has CL:ERROR initform.
* All slots are not specified :READ-ONLY T.

Because, copier evaluates ‘CL:MAKE-INSTANCE‘ without any initargs,
then ‘CL:SETF‘ each slots.

## Usage

## From developer

* Product’s goal - already?
* License - MIT
### Tested
* SBCL/2.0.2
* CCL/1.12
* CLISP/2.49
* ECL/20.4.24

Version

0.0.7

Dependencies
Source

structure-ext.as-class.asd (file)

Component

as-class.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

2 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

2.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.1 structure-ext.asd

Location

structure-ext.asd

Systems

structure-ext (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.2 structure-ext.left-arrow-accessors.asd

Location

accessors/structure-ext.left-arrow-accessors.asd

Systems

structure-ext.left-arrow-accessors (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.3 structure-ext.make-instance.asd

Location

make-instance/structure-ext.make-instance.asd

Systems

structure-ext.make-instance (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.4 structure-ext.as-class.asd

Location

as-class/structure-ext.as-class.asd

Systems

structure-ext.as-class (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.5 structure-ext/package.lisp

Parent

structure-ext (system)

Location

package.lisp

Packages

structure-ext


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.6 structure-ext.left-arrow-accessors/left-arrow-accessors.lisp

Parent

structure-ext.left-arrow-accessors (system)

Location

accessors/left-arrow-accessors.lisp

Packages

structure-ext.left-arrow-accessors

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.7 structure-ext.make-instance/make-instance.lisp

Parent

structure-ext.make-instance (system)

Location

make-instance/make-instance.lisp

Packages

structure-ext.make-instance


Previous: , Up: Lisp files   [Contents][Index]

2.1.8 structure-ext.as-class/as-class.lisp

Parent

structure-ext.as-class (system)

Location

as-class/as-class.lisp

Packages

structure-ext.as-class

Exported Definitions

defstruct* (macro)

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

3 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

3.1 structure-ext

Source

package.lisp (file)

Use List

Next: , Previous: , Up: Packages   [Contents][Index]

3.2 structure-ext.left-arrow-accessors

Source

left-arrow-accessors.lisp (file)

Nickname

larac

Use List
Used By List

structure-ext

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

3.3 structure-ext.make-instance

Source

make-instance.lisp (file)

Nickname

makins

Use List

common-lisp


Previous: , Up: Packages   [Contents][Index]

3.4 structure-ext.as-class

Source

as-class.lisp (file)

Nickname

as-class

Use List

common-lisp

Used By List

structure-ext

Exported Definitions

defstruct* (macro)

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

4.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

4.1.1 Macros

Macro: define-left-arrow-accessors TYPE &rest SLOT*

# DEFINE-LEFT-ARROW-ACCESSORS

## Description:
Define accessor aliases.

“‘lisp
#?(defstruct foo bar bazz)
=> FOO
, :lazy
“‘

“‘lisp
#?(define-left-arrow-accessors foo bar)
=> (BAR<=FOO)
, :test
“‘

“‘lisp
#?(bar<=foo (make-foo :bar 0))
=> 0
, :around
“‘

“‘lisp
#?(bazz<=foo (make-foo :bazz 0))
:signals (or undefined-function
warning ; for ccl
)
“‘

### syntax
(DEFINE-LEFT-ARROW-ACCESSORS type &rest slot\*)
=> result

## Arguments and Values:
type := symbol which is structure name, otherwise error.

“‘lisp
#?(define-left-arrow-accessors "FOO" bazz)
:signals error
“‘

“‘lisp
#?(define-left-arrow-accessors bar bazz)
:signals error
“‘
slot* := symbol which is slot-name, otherwise error.

“‘lisp
#?(define-left-arrow-accessors foo "BAR")
:signals error
“‘

“‘lisp
#?(define-left-arrow-accessors foo hoge)
:signals error
“‘
result := list which includes defined accessor names.

## Affected By:
lisp image status.

## Side-Effects:
define new functions in current package.

## Notes:

## Exceptional-Situations:

Package

structure-ext.left-arrow-accessors

Source

left-arrow-accessors.lisp (file)

Macro: defstruct* &body BODY

# DEFSTRUCT\*

## Description:
Define class by defstruct syntax.

### syntax
(DEFSTRUCT\* &body body)
=> result

“‘lisp
#?(defstruct* foo bar)
=> FOO
, :lazy
“‘

“‘lisp
#?(make-foo)
:be-the foo
“‘

“‘lisp
#?(foo-bar (make-foo :bar 0))
=> 0
“‘

“‘lisp
#?(foo-p (make-foo))
:satisfies identity
“‘

“‘lisp
#?(let* ((foo (make-foo :bar 0))
(copied (copy-foo foo)))
(values (eq foo copied)
(foo-bar copied)))
:multiple-value-satisfies (lambda ($samep $copied-bar-value)
(& (null $samep)
(= 0 $copied-bar-value)))
“‘

## Arguments and Values:
see CL:DEFSTRUCT.

## Affected By:
none

## Side-Effects:
none

## Notes:

## Exceptional-Situations:
:initial-offset, :type and :named option is invalid.

“‘lisp
#?(defstruct* (bar (:type list))
hoge fuga)
:signals error
“‘

“‘lisp
#?(defstruct* (bar (:initial-offset 4))
hoge fuga)
:signals error
“‘
specify both :print-function and :print-object is invalid.

“‘lisp
#?(defstruct* (bar (:print-function bar-printer)
(:print-object (lambda (&rest args) (print args))))
hoge fuga)
:signals error
“‘

## Examples
simplest form

“‘lisp
#?(defstruct* hoge bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
with initform.

“‘lisp
#?(defstruct* hoge
(bar 0))
; <— specified.
:expanded-to
“‘
Specify type.

“‘lisp
#?(defstruct* hoge
(bar 0 :type integer))
; <— specified.
:expanded-to
“‘
Specify read-only T.

“‘lisp
#?(defstruct* hoge
(bar 0 :read-only T))
; <— specified.
:expanded-to
“‘
Conc-name option example.
Specify no prefix.

“‘lisp
#?(defstruct* (hoge (:conc-name nil)) ; <— Specify.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor bar))) ; <— This! (defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Same above.

“‘lisp
#?(defstruct* (hoge (:conc-name)) bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor bar))) ; <— This! (defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Specify alternative.

“‘lisp
#?(defstruct* (hoge (:conc-name hoge-)) ; <— Specify
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar))) ; <— This! (defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Can use string-designator.

“‘lisp
#?(defstruct* (hoge (:conc-name "hoge-")) ; <— use string.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor |hoge-BAR|))) ; <— This! (defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Examples of :constructor option.

“‘lisp
#?(defstruct* (hoge (:constructor make)) ; <— Specify.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make ; <— This!
(&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘

“‘lisp
#?(defstruct* (hoge (:constructor)) ; <— No arg means use default. bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge ; <— This!
(&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘

“‘lisp
#?(defstruct* (hoge (:constructor create-hoge
(a &optional b (c ’sea) &rest d &aux e (f ’eff))))
a b c d e f)
:expanded-to (progn (defclass hoge ()
((a :initform nil :initarg :a :accessor hoge-a)
(b :initform nil :initarg :b :accessor hoge-b)
(c :initform nil :initarg :c :accessor hoge-c)
(d :initform nil :initarg :d :accessor hoge-d)
(e :initform nil :initarg :e :accessor hoge-e)
(f :initform nil :initarg :f :accessor hoge-f)))
;; This!
(defun create-hoge (a &optional b (c ’sea) &rest d &aux e (f ’eff)) (make-instance ’hoge :a a :b b :c c :d d :e e :f f))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Examples of :copier option.

“‘lisp
#?(defstruct* (hoge (:copier nil)) ; specify nil.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
;; No cpier!
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘

“‘lisp
#?(defstruct* (hoge (:copier hoge)) ; specify name.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
;; This!
(defgeneric hoge (arg))
;; Also!
(defmethod hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
Examples of :include option.

“‘lisp
#?(defstruct* (hoge (:include foo)) fuga)
:expanded-to (progn (defclass hoge (foo) ; <— This!
((fuga :initform nil :initarg :fuga :accessor hoge-fuga)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
;; These!
(defgeneric hoge-bar (arg))
(defmethod hoge-bar ((arg hoge))
(foo-bar arg))
(defgeneric (setf hoge-bar) (new arg))
(defmethod (setf hoge-bar) (new (arg hoge))
(setf (foo-bar arg) new))
’hoge)
“‘
Some :include options are valid.
Lets say another object bazz.

“‘lisp
#?(defstruct* bazz
(piyo 0 :read-only t))
=> BAZZ
, :lazy
“‘

“‘lisp
#?(defstruct* (hoge (:include foo)
(:include bazz)) ; <— This!
fuga)
:expanded-to (progn (defclass hoge (foo bazz) ; <— This!
((fuga :initform nil :initarg :fuga :accessor hoge-fuga)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
;; These!
(defgeneric hoge-bar (arg))
(defmethod hoge-bar ((arg hoge))
(foo-bar arg))
(defgeneric (setf hoge-bar) (new arg))
(defmethod (setf hoge-bar) (new (arg hoge))
(setf (foo-bar arg) new))
(defgeneric hoge-piyo (arg))
(defmethod hoge-piyo ((arg hoge))
(bazz-piyo arg))
’hoge)
“‘
Slot description example.

“‘lisp
#?(defstruct* (hoge (:include foo (bar 0)))
fuga)
:expanded-to (progn (defclass hoge (foo)
((fuga :initform nil :initarg :fuga :accessor hoge-fuga)) (:default-initargs :bar 0)) ; <— This!
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
(defgeneric hoge-bar (arg))
(defmethod hoge-bar ((arg hoge))
(foo-bar arg))
(defgeneric (setf hoge-bar) (new arg))
(defmethod (setf hoge-bar) (new (arg hoge))
(setf (foo-bar arg) new))
’hoge)
“‘
Examples of :predicate option.

“‘lisp
#?(defstruct* (hoge (:predicate nil)) ; specify nil.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
;; No predicate!
’hoge)
“‘

“‘lisp
#?(defstruct* (hoge (:predicate hoge)) ; specify name.
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
;; This!
#+(or clisp sbcl)
(defun hoge (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge (arg))
#-(or clisp sbcl)
(defmethod hoge ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
:print-function

“‘lisp
#?(defstruct* (hoge (:print-function printer)) ; <— specify
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
;; This!
(defmethod print-object ((obj hoge) stream)
(printer obj stream *print-level*))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘
:print-object

“‘lisp
#?(defstruct* (hoge (:print-object printer)) ; <— specify
bar)
:expanded-to (progn (defclass hoge ()
((bar :initform nil :initarg :bar :accessor hoge-bar)))
(defun make-hoge (&rest args)
(apply #’make-instance ’hoge args))
;; This!
(defmethod print-object ((obj hoge) stream)
(printer obj stream))
(defgeneric copy-hoge (arg))
(defmethod copy-hoge ((arg hoge))
(let ((obj (make-instance (class-of arg))))
(dolist (slot (slots<=obj arg))
(if (slot-boundp arg slot)
(setf (slot-value obj slot) (slot-value arg slot)) (slot-makunbound obj slot)))
obj))
#+(or clisp sbcl)
(defun hoge-p (arg) (typep arg ’hoge))
#-(or clisp sbcl)
(defgeneric hoge-p (arg))
#-(or clisp sbcl)
(defmethod hoge-p ((arg hoge)) arg)
#-(or clisp sbcl)
(defmethod hoge-p (arg)
(declare (ignore arg))
nil)
’hoge)
“‘

Package

structure-ext.as-class

Source

as-class.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

4.1.2 Conditions

Condition: missing-symbol ()

# MISSING-SYMBOL

## Description:

## Class Precedence List: (case in SBCL)
missing-symbol simple-error simple-condition program-error error serious-condition condition slot-object t

## Effective Slots:
FORMAT-CONTROL [Type] T
[READER] simple-condition-format-control
FORMAT-ARGUMENTS [Type] T
[READER] simple-condition-format-arguments

## Notes:

Package

structure-ext.left-arrow-accessors

Source

left-arrow-accessors.lisp (file)

Direct superclasses
  • program-error (condition)
  • simple-error (condition)

Previous: , Up: Definitions   [Contents][Index]

4.2 Internal definitions


Previous: , Up: Internal definitions   [Contents][Index]

4.2.1 Functions

Function: accessors TYPE SLOTS
Package

structure-ext.left-arrow-accessors

Source

left-arrow-accessors.lisp (file)

Function: accessors NAME OPTIONS
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: check OPTIONS
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: collect-option OPTION OPTIONS
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: conc-name OPTIONS CLASS-NAME
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: constructors NAME OPTIONS
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: copier NAME OPTIONS
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: enslot SLOT CONC-NAME
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: left-arrow-names TYPE SLOTS
Package

structure-ext.left-arrow-accessors

Source

left-arrow-accessors.lisp (file)

Function: may-documentation DOC
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: may-generic METHOD &optional LAMBDA-LIST
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: may-initargs OPTIONS
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: method-name CONC-NAME SLOT-NAME
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: parse BODY
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: predicate NAME OPTIONS
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: print-function NAME OPTIONS
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: slots SLOTS OPTIONS CLASS-NAME
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: slots<=obj OBJ
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: super-classes OPTIONS
Package

structure-ext.as-class

Source

as-class.lisp (file)

Function: the-defun-forms LEFT-ARROW-NAMES ACCESSORS
Package

structure-ext.left-arrow-accessors

Source

left-arrow-accessors.lisp (file)

Function: the-setf-forms LEFT-ARROW-NAMES ACCESSORS
Package

structure-ext.left-arrow-accessors

Source

left-arrow-accessors.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   S  
Index Entry  Section

F
File, Lisp, structure-ext.as-class.asd: The structure-ext․as-class․asd file
File, Lisp, structure-ext.as-class/as-class.lisp: The structure-ext․as-class/as-class․lisp file
File, Lisp, structure-ext.asd: The structure-ext․asd file
File, Lisp, structure-ext.left-arrow-accessors.asd: The structure-ext․left-arrow-accessors․asd file
File, Lisp, structure-ext.left-arrow-accessors/left-arrow-accessors.lisp: The structure-ext․left-arrow-accessors/left-arrow-accessors․lisp file
File, Lisp, structure-ext.make-instance.asd: The structure-ext․make-instance․asd file
File, Lisp, structure-ext.make-instance/make-instance.lisp: The structure-ext․make-instance/make-instance․lisp file
File, Lisp, structure-ext/package.lisp: The structure-ext/package․lisp file

L
Lisp File, structure-ext.as-class.asd: The structure-ext․as-class․asd file
Lisp File, structure-ext.as-class/as-class.lisp: The structure-ext․as-class/as-class․lisp file
Lisp File, structure-ext.asd: The structure-ext․asd file
Lisp File, structure-ext.left-arrow-accessors.asd: The structure-ext․left-arrow-accessors․asd file
Lisp File, structure-ext.left-arrow-accessors/left-arrow-accessors.lisp: The structure-ext․left-arrow-accessors/left-arrow-accessors․lisp file
Lisp File, structure-ext.make-instance.asd: The structure-ext․make-instance․asd file
Lisp File, structure-ext.make-instance/make-instance.lisp: The structure-ext․make-instance/make-instance․lisp file
Lisp File, structure-ext/package.lisp: The structure-ext/package․lisp file

S
structure-ext.as-class.asd: The structure-ext․as-class․asd file
structure-ext.as-class/as-class.lisp: The structure-ext․as-class/as-class․lisp file
structure-ext.asd: The structure-ext․asd file
structure-ext.left-arrow-accessors.asd: The structure-ext․left-arrow-accessors․asd file
structure-ext.left-arrow-accessors/left-arrow-accessors.lisp: The structure-ext․left-arrow-accessors/left-arrow-accessors․lisp file
structure-ext.make-instance.asd: The structure-ext․make-instance․asd file
structure-ext.make-instance/make-instance.lisp: The structure-ext․make-instance/make-instance․lisp file
structure-ext/package.lisp: The structure-ext/package․lisp file

Jump to:   F   L   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   C   D   E   F   L   M   P   S   T  
Index Entry  Section

A
accessors: Internal functions
accessors: Internal functions

C
check: Internal functions
collect-option: Internal functions
conc-name: Internal functions
constructors: Internal functions
copier: Internal functions

D
define-left-arrow-accessors: Exported macros
defstruct*: Exported macros

E
enslot: Internal functions

F
Function, accessors: Internal functions
Function, accessors: Internal functions
Function, check: Internal functions
Function, collect-option: Internal functions
Function, conc-name: Internal functions
Function, constructors: Internal functions
Function, copier: Internal functions
Function, enslot: Internal functions
Function, left-arrow-names: Internal functions
Function, may-documentation: Internal functions
Function, may-generic: Internal functions
Function, may-initargs: Internal functions
Function, method-name: Internal functions
Function, parse: Internal functions
Function, predicate: Internal functions
Function, print-function: Internal functions
Function, slots: Internal functions
Function, slots<=obj: Internal functions
Function, super-classes: Internal functions
Function, the-defun-forms: Internal functions
Function, the-setf-forms: Internal functions

L
left-arrow-names: Internal functions

M
Macro, define-left-arrow-accessors: Exported macros
Macro, defstruct*: Exported macros
may-documentation: Internal functions
may-generic: Internal functions
may-initargs: Internal functions
method-name: Internal functions

P
parse: Internal functions
predicate: Internal functions
print-function: Internal functions

S
slots: Internal functions
slots<=obj: Internal functions
super-classes: Internal functions

T
the-defun-forms: Internal functions
the-setf-forms: Internal functions

Jump to:   A   C   D   E   F   L   M   P   S   T  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables


Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   M   P   S  
Index Entry  Section

C
Condition, missing-symbol: Exported conditions

M
missing-symbol: Exported conditions

P
Package, structure-ext: The structure-ext package
Package, structure-ext.as-class: The structure-ext․as-class package
Package, structure-ext.left-arrow-accessors: The structure-ext․left-arrow-accessors package
Package, structure-ext.make-instance: The structure-ext․make-instance package

S
structure-ext: The structure-ext system
structure-ext: The structure-ext package
structure-ext.as-class: The structure-ext․as-class system
structure-ext.as-class: The structure-ext․as-class package
structure-ext.left-arrow-accessors: The structure-ext․left-arrow-accessors system
structure-ext.left-arrow-accessors: The structure-ext․left-arrow-accessors package
structure-ext.make-instance: The structure-ext․make-instance system
structure-ext.make-instance: The structure-ext․make-instance package
System, structure-ext: The structure-ext system
System, structure-ext.as-class: The structure-ext․as-class system
System, structure-ext.left-arrow-accessors: The structure-ext․left-arrow-accessors system
System, structure-ext.make-instance: The structure-ext․make-instance system

Jump to:   C   M   P   S