The cl-mop Reference Manual

Table of Contents

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

The cl-mop Reference Manual

This is the cl-mop Reference Manual, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:15:31 2018 GMT+0.


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

1 Introduction

cl-mop

Basic tools to make dealing with CLOS easier and portable

The goal of this library is to provide portable Common Lisp facilities for working with CLOS instances. This first release is minimal because I'm following my usual MO of only implementing things as I need them. There is therefore no call for me to go beyond slot-names, map-slots, shallow-copy and deep-copy yet (and I've used deep-copy in exactly one place so far, so be wary of that one; the others have been at least slightly battle-tested).

Supports

In theory, it supports CMUCL, Lispworks, SBCL, Allegro CL, GNU Clisp and OpenMCL with native threads. Really, I've only deployed it with SBCL and did some cursory testing with GNU Clisp. If someone tries it out extensively elsewhere, let me know. As always, patches welcome for CLs not on that list.

Exports

All of the exported symbols designate methods and not functions. While I've found the defaults published here to be useful and adequate, there are a lot of crazy things you can do with CLOS that I don't even try to account for. If you have special cases on hand, you can easily define your own methods for those and carry on as normal where cl-mop is sufficient.

In addition to these symbols, cl-mop also re-exports class-slots and slot-definition-name. These functions are imported in a portable fashion which accounts for the different providing packages accross different CL implementations.

slot-names

Designates two methods; one acting on classes and one acting on instances. In both cases, it returns a list of symbols designating the slot-names of the argument.

map-slots

Takes a function and an instance, and returns the sequence resulting from running the function on (slot-name slot-value) over each bound slot in an instance. It silently ignores unbound slots, you won't even get a NIL in the resulting list.

to-alist

Takes an instance and returns the alist of ((slot-name . value) ...) for all bound slots. The trivial application of map-slots, included because I found myself using it quite often.

shallow-copy

Takes a CLOS instance and returns a shallow copy of it. I've found this useful in a bunch of places where I really want a copy of an existing instance with one or two slots changed (but don't want to destructively modify the underlying instance).

deep-copy

Takes a CLOS instance and returns a deep copy of it. That is, it allocates a new instance, then deep-copies each slot. USE CAUTION Like I said, I use this in exactly one place, and the only reason shallow-copy won't do there is that one of the slots is a vector I need to change (doing this to a shallow copy would change both the copy and the original). It works in that one use case, but I wouldn't count on it if I was doing something much crazier.

License

This library is hereby released for public consumption under the Expat license, reproduced below and in a separate LICENSE file.

Copyright (c) 2012 Inaimathi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


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

2 Systems

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


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

2.1 cl-mop

Author

Inaimathi <leo.zovic@example.com>

License

Expat (MIT-style)

Description

Simple, portable tools for dealing with CLOS objects.

Source

cl-mop.asd (file)

Components

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

3 Files

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


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

3.1 Lisp


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

3.1.1 cl-mop.asd

Location

cl-mop.asd

Systems

cl-mop (system)


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

3.1.2 cl-mop/package.lisp

Parent

cl-mop (system)

Location

package.lisp

Packages

cl-mop


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

3.1.3 cl-mop/cl-mop.lisp

Dependency

package.lisp (file)

Parent

cl-mop (system)

Location

cl-mop.lisp

Exported Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 cl-mop

Source

package.lisp (file)

Use List

common-lisp

Exported Definitions

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

5 Definitions

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


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

5.1 Exported definitions


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

5.1.1 Generic functions

Generic Function: deep-copy OBJECT

Does a general deep-copy on the given object and sub-pieces.
Returns atoms, numbers and chars.
Runs copy-tree on lists, and copy-seq on other sequences.
Runs copy-structure on pathnames, hash tables and other structure-objects

Package

cl-mop

Source

cl-mop.lisp (file)

Methods
Method: deep-copy (OBJECT structure-object)

A deep copy of a structure-object is (copy-structure object).

Method: deep-copy (OBJECT list)

A deep copy of a list is (copy-tree list)

Method: deep-copy (OBJECT sequence)

A deep copy of a general sequence is merely (copy-seq sequence).

Method: deep-copy (OBJECT standard-object)

The default deep copy specializes on STANDARD-OBJECT. It takes an object and returns a deep copy.

Method: deep-copy OBJECT

The default unspecialized case should only catch atoms, numbers and characters. It merely returns its results.

Generic Function: map-slots FUNCTION INSTANCE

Takes a binary function and an instance.
Returns the sequence resulting from calling the function on each bound (slot-name slot-value) of instance

Package

cl-mop

Source

cl-mop.lisp (file)

Methods
Method: map-slots (FN function) (INSTANCE standard-object)

The default case of map-slots specializes on STANDARD-OBJECT.

Method: map-slots (FN function) (INSTANCE error)
Generic Function: shallow-copy OBJECT

Provides a general shallow-copy function for CLOS objects. If you’ve got a special case, write a new defmethod.

Package

cl-mop

Source

cl-mop.lisp (file)

Methods
Method: shallow-copy (OBJECT standard-object)

The default shallow copy specializes on STANDARD-OBJECT. It takes an object and returns a shallow copy.

Generic Function: slot-names OBJECT
Package

cl-mop

Methods
Method: slot-names (CLASS standard-class)
Source

cl-mop.lisp (file)

Method: slot-names (OBJECT standard-object)
Source

cl-mop.lisp (file)

Method: slot-names (OBJECT error)
Source

cl-mop.lisp (file)

Generic Function: to-alist INSTANCE
Package

cl-mop

Methods
Method: to-alist (INSTANCE standard-object)

Returns an assoc list of (k . v) pairs from the given instances’ slots and slot-values. This is meant to provide an easy way of showing

Source

cl-mop.lisp (file)

Method: to-alist (INSTANCE error)
Source

cl-mop.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-mop.asd: The cl-mop<dot>asd file
cl-mop/cl-mop.lisp: The cl-mop/cl-mop<dot>lisp file
cl-mop/package.lisp: The cl-mop/package<dot>lisp file

F
File, Lisp, cl-mop.asd: The cl-mop<dot>asd file
File, Lisp, cl-mop/cl-mop.lisp: The cl-mop/cl-mop<dot>lisp file
File, Lisp, cl-mop/package.lisp: The cl-mop/package<dot>lisp file

L
Lisp File, cl-mop.asd: The cl-mop<dot>asd file
Lisp File, cl-mop/cl-mop.lisp: The cl-mop/cl-mop<dot>lisp file
Lisp File, cl-mop/package.lisp: The cl-mop/package<dot>lisp file

Jump to:   C   F   L  

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

A.2 Functions

Jump to:   D   G   M   S   T  
Index Entry  Section

D
deep-copy: Exported generic functions
deep-copy: Exported generic functions
deep-copy: Exported generic functions
deep-copy: Exported generic functions
deep-copy: Exported generic functions
deep-copy: Exported generic functions

G
Generic Function, deep-copy: Exported generic functions
Generic Function, map-slots: Exported generic functions
Generic Function, shallow-copy: Exported generic functions
Generic Function, slot-names: Exported generic functions
Generic Function, to-alist: Exported generic functions

M
map-slots: Exported generic functions
map-slots: Exported generic functions
map-slots: Exported generic functions
Method, deep-copy: Exported generic functions
Method, deep-copy: Exported generic functions
Method, deep-copy: Exported generic functions
Method, deep-copy: Exported generic functions
Method, deep-copy: Exported generic functions
Method, map-slots: Exported generic functions
Method, map-slots: Exported generic functions
Method, shallow-copy: Exported generic functions
Method, slot-names: Exported generic functions
Method, slot-names: Exported generic functions
Method, slot-names: Exported generic functions
Method, to-alist: Exported generic functions
Method, to-alist: Exported generic functions

S
shallow-copy: Exported generic functions
shallow-copy: Exported generic functions
slot-names: Exported generic functions
slot-names: Exported generic functions
slot-names: Exported generic functions
slot-names: Exported generic functions

T
to-alist: Exported generic functions
to-alist: Exported generic functions
to-alist: Exported generic functions

Jump to:   D   G   M   S   T  

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

A.3 Variables


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

A.4 Data types

Jump to:   C   P   S  
Index Entry  Section

C
cl-mop: The cl-mop system
cl-mop: The cl-mop package

P
Package, cl-mop: The cl-mop package

S
System, cl-mop: The cl-mop system

Jump to:   C   P   S