# The cambl Reference Manual

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

# The cambl Reference Manual

This is the cambl Reference Manual, version 4.0.0, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 10:51:34 2018 GMT+0.

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

## 1 Introduction

```#+TITLE: CAMBL

*Commoditized Amounts and Balances*\\

This library provides a convenient facility for working with
commoditized values. It does not allow compound units -- and so is not
suited for scientific operations -- but does work rather nicely for
the purpose of financial calculations.

The primary entry point to using this library is the creation of
/VALUES/, which may be of many different types. These /VALUES/ are
then used as arguments to a set of basic mathematical /OPERATIONS/,
which also yield /VALUES/. However, the type of the result may not be
the same type as either of the operands.

For example, let's say you want to create a figure representing 10 US
dollars. You then add an /INTEGER/ to this amount, the number 200. The
result of such an operation will be an amalgam of the two units
involved: Dollars, and No-units. This dual-commodity value is
represented as a /BALANCE/ object, whose printed form shows each
commodity amount on its own line. For example:

#+BEGIN_SRC lisp
(let ((value (cambl:amount "\$100.00")))
=> 200
\$100.00
#+END_SRC

that is: math involving commodity units. Unlike scientific units,
there is no concept of "compound" units. If you divide 1kg by 1m, you
do not get "1 kg/m", but "1 kg" (the unit of the second operand is
ignored for multiplication and division). The intended use of this
library is in situations such as computing financial transactions.

* Amounts

There are just a few main entry points to the *CAMBL* library for
dealing with amounts (which is mainly how you'll use it). Here is
a quick list, following by a description in the context of a REPL
session. Note that where the name contains value, it will work for
integers, amounts and balances. If it contains amount or balance, it
only operates on entities of that type.

|-------------------+----------------------------------------------------|
| Function          | Description                                        |
|-------------------+----------------------------------------------------|
| amount[*]         | create an amount from a string                     |
|-------------------+----------------------------------------------------|
| exact-amount      | create an amount from a string which overrides     |
|                   | its commodity's display precision; this feature    |
|                   | "sticks" through any math operations               |
|-------------------+----------------------------------------------------|
| parse-amount[*]   | parse an amount from a string (alias for 'amount') |
|-------------------+----------------------------------------------------|
|-------------------+----------------------------------------------------|
|-------------------+----------------------------------------------------|
| format-value      | format a value to a string                         |
|-------------------+----------------------------------------------------|
| print-value       | print a value to a stream                          |
|-------------------+----------------------------------------------------|
| add               | perform math using values; the values are          |
| subtract          | changed as necessary to preserve information       |
| multiply          | (adding two amounts may result in a                |
| divide            | balance).                                          |
|-------------------+----------------------------------------------------|
| value-zerop       | would the value display as zero?                   |
|-------------------+----------------------------------------------------|
| value-zerop*      | is the value truly zero?                           |
|-------------------+----------------------------------------------------|
| value-minusp      | would the amount display as a negative amount?     |
|-------------------+----------------------------------------------------|
| value-minusp*     | is the amount truly negative?                      |
|-------------------+----------------------------------------------------|
| value-plusp       | would it display as an amount greater than zero?   |
|-------------------+----------------------------------------------------|
| value-plusp*      | is it truly greater than zero?                     |
|-------------------+----------------------------------------------------|
| value=            | compare two values                                 |
| value/=           |                                                    |
|-------------------+----------------------------------------------------|
| value<            | compare values (not meaningful for all values,     |
| value<=           | such as balances)                                  |
| value>            |                                                    |
| value>=           |                                                    |
|-------------------+----------------------------------------------------|
| value-equal       | compare two values for exact match                 |
|-------------------+----------------------------------------------------|
| value-equalp      | compare two values only after rounding to what     |
|                   | would be shown to the user (approximate match)     |
|                   | -- this is the same as value=                      |
|-------------------+----------------------------------------------------|
| value-not-equal   | compare if two values for not an exact match       |
|-------------------+----------------------------------------------------|
| value-not-equalp  | compare two values after commodity rounding        |
|-------------------+----------------------------------------------------|
| value-lessp       | same as value<                                     |
|-------------------+----------------------------------------------------|
| value-lessp*      | compare if a < b exactly, with full precision      |
|-------------------+----------------------------------------------------|
| value-lesseqp     | same as value<=                                    |
|-------------------+----------------------------------------------------|
| value-lesseqp*    | exact version of value<=                           |
|-------------------+----------------------------------------------------|
| value-greaterp    | same as value>                                     |
|-------------------+----------------------------------------------------|
| value-greaterp*   | exact version of value>                            |
|-------------------+----------------------------------------------------|
| value-greatereqp  | same as value>=                                    |
|-------------------+----------------------------------------------------|
| value-greatereqp* | exact version of value>=                           |
|-------------------+----------------------------------------------------|
| amount-precision  | return the internal precision of an amount         |
|-------------------+----------------------------------------------------|
| display-precision | return the "display" precision for an amount       |
|                   | or a commodity                                     |
|-------------------+----------------------------------------------------|

* Example Session

Interacting with *CAMBL* begins with creating an amount. This is done
most easily from a string, but it can also be read from a stream:

#+BEGIN_SRC lisp
(cambl:amount "\$100.00")
=> #

(with-input-from-string (in "\$100.00")
=> #
#+END_SRC

When you parse an amount using one of these two functions, *CAMBL*
creates a /COMMODITY/ class for you, whose symbol name is "\$". This
class remembers details about how you used the commodity, such as the
input precision and the format of the commodity symbol. Some of these
details can be inspected by looking at the amount's commodity
directly:

#+BEGIN_SRC lisp
(cambl:amount-commodity (cambl:amount "\$100.00"))
=> #
#+END_SRC

Here you can see that the commodity for \$100.00 is \$, and it knows
that the commodity should be prefixed to the amount, and that it gets
connected to the amount. This commodity was used without any "thousand
marks" (i.e. \$1000.00 vs \$1,000.00), and it has a maximum display
precision of TWO observed so far. If we print such an amount, we'll
see the same style as was input:

#+BEGIN_SRC lisp
(cambl:format-value (cambl:amount "\$100.00"))
=> "\$100.00"
(cambl:print-value (cambl:amount "\$100.00"))
=> NIL
\$100.00
#+END_SRC

*CAMBL* observed how you used the "\$" commodity, and now reports back
all dollar figures after the same fashion. Even though there are no
cents in the amounts above, *CAMBL* will still record a full two
digits of precision (this becomes important during division, to guard
against fractional losses during repeated rounding).

#+BEGIN_SRC lisp
(cambl:amount-precision (cambl:amount "\$100.00"))
=> 2
#+END_SRC

*CAMBL* remembers the greatest precision it has seen thus far, but
never records a lesser precision. So if you parse \$100.00 and then
\$100, both values will be printed as \$100.00.

There are three functions for creating amounts, but they have some
subtle differences where precision is concerned. They are: ~amount~,
~amount*~, and ~exact-amount~. Here are the differences:

#+BEGIN_SRC lisp
(cambl:amount "\$100.00")
=> #
#+END_SRC

- amount has an internal precision of 2
- commodity \$ has a display precision of 2 (if no other
amount using a higher precision was observed so far)
- when printing, amount uses the commodity's precision

#+BEGIN_SRC lisp
(cambl:format-value *)
=> "\$100.00"
(cambl:format-value ** :full-precision-p t)
=> "\$100.00"
#+END_SRC

#+BEGIN_SRC lisp
(cambl:amount* "\$100.0000")
=> #
#+END_SRC

- amount has an internal precision of 4
- commodity \$ still has a display precision of 2 (from above)
- when printing, amount uses the commodity's precision

#+BEGIN_SRC lisp
(cambl:format-value *)
=> "\$100.00"
(cambl:format-value ** :full-precision-p t)
=> "\$100.0000"
#+END_SRC

#+BEGIN_SRC lisp
(cambl:exact-amount "\$100.0000")
=> #
#+END_SRC

- amount has an internal precision of 4
- commodity \$ still has a display precision of 2 (from above)
- when printing, amount uses its internal precision

#+BEGIN_SRC lisp
(cambl:format-value *)
=> "\$100.0000"
(cambl:format-value ** :full-precision-p t)
=> "\$100.0000"
#+END_SRC

There are similar variants for the stream reading functions:

Internally, an amount's quantity is stored as a rational number, and
therefore has a perfect precision. The internal precision field of an
amount tries to keep track of the number of decimals to display when
printing a value with the ~FULL-PRECISION-P~ option.

By default, uncommoditized amounts (which are in fact just rational
numbers), are displayed with a precision of 3. This can be changed by
setting ~CAMBL:*DEFAULT-DISPLAY-PRECISION*~. When they are used in
math operations, their considered internal precision to compute the
result's internal precision is at most ~CAMBL:*EXTRA-PRECISION*~
(which is 6 by default).

_NOTE:_ The ~KEEP-PRECISION-P~ property of an amount carries through
any math operations involving that amount, so that the final result is
always displayed using its own internal percision.

The point of all this is that amounts are displayed as the user
expects them to be, but internally never lose information. In fact, if
you divide two high internal precision amounts together, you'll get
a new amount with a very high internal precision, but which still
displays as expected:

#+BEGIN_SRC lisp
(setf *tmp* (cambl:divide (cambl:amount "\$100.00")
(cambl:amount "50000000")))

(cambl:format-value *tmp* :full-precision-p t)
=> "\$0.0000020000000000"
(cambl:format-value *tmp*)
=> "\$0.00"
#+END_SRC

You'll notice here that the amount displayed is not
\$0.00000200000000002. This is because *CAMBL* does not try to capture
every digit resulting from a division; rather, it keeps six more
digits of precision than is strictly necessary so that even after
millions of calculations, not a penny is lost. If you find this is not
enough slack for your calculations, you can set
~CAMBL:*EXTRA-PRECISION*~ to a higher or lower value.

* Commodities

*CAMBL* offers several methods for accessing the commodity information
relating to amounts:

|--------------------------+---------------------------------------------|
| Function                 | Description                                 |
|--------------------------+---------------------------------------------|
| amount-commodity         | the COMMODITY referenced by an amount       |
|--------------------------+---------------------------------------------|
| display-precision        | display precision of an AMOUNT or COMMODITY |
|--------------------------+---------------------------------------------|
| commodity-qualified-name | the name used print a COMMODITY             |
|--------------------------+---------------------------------------------|

```

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

## 2 Systems

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

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

### 2.1 cambl

Maintainer

Christophe Junke <junke.christophe@gmail.com>

Author

Johh Wiegley <jwiegley@gmail.com>

BSD-3

Description

A library for working with financial amounts involving multiple commodities.

Version

4.0.0

Dependencies
• cl-containers
• local-time
• periods
• fprog (system)
• alexandria
Source

cambl.asd (file)

Component

cambl.lisp (file)

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

### 2.2 fprog

Maintainer

Christophe Junke <junke.christophe@gmail.com>

Author

Johh Wiegley <jwiegley@gmail.com>

BSD-3

Description

Functional programming utilities: iteration over immutable lists sharing identical sublists.

Version

1.0.0

Source

fprog.asd (file)

Component

fprog.lisp (file)

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 cambl.asd

Location

cambl.asd

Systems

cambl (system)

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

#### 3.1.2 fprog.asd

Location

fprog.asd

Systems

fprog (system)

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

#### 3.1.3 cambl/cambl.lisp

Parent

cambl (system)

Location

cambl.lisp

Packages
Exported Definitions
Internal Definitions

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

#### 3.1.4 fprog/fprog.lisp

Parent

fprog (system)

Location

fprog.lisp

Packages
Exported Definitions
Internal Definitions

timing-tests (function)

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

## 4 Packages

Packages are listed by definition order.

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

### 4.1 cambl

Source

cambl.lisp (file)

Use List
• alexandria.0.dev
• periods
• local-time
• common-lisp
Exported Definitions
Internal Definitions

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

### 4.2 fprog

Source

fprog.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

timing-tests (function)

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

## 5 Definitions

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

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

### 5.1 Exported definitions

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

#### 5.1.1 Special variables

Special Variable: *default-commodity-pool*
Package
Source

cambl.lisp (file)

Special Variable: *default-display-precision*
Package
Source

cambl.lisp (file)

Special Variable: *extra-precision*
Package
Source

cambl.lisp (file)

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

#### 5.1.2 Macros

Macro: apply-to-list LIST PREDICATE FUNCTION &key FIRST-ONLY SKIP-TO-NEXT LOOKAHEAD

Given an input LIST, replicate as much of its structure as possible
while applying some kind of transform on its value.

For every member of the list where PREDICATE returns T, FUNCTION is called with the list whose CAR is that member; FUNCTION should return the list which will be substituted at that point (this makes it possible to remove, change or insert the matched cell). If FIRST-ONLY is NIL, this is only done for every cell that matches. Note: Be very careful when setting FIRST-ONLY to T, for if FUNCTION returns a new list that also matches PREDICATE, an infinitely recursive loop can occur. If SKIP-TO-NEXT is T, scanning the function contains with the CDR of the value returned by FUNCTION, which can never lead to infinite recursion. If LOOKAHEAD is T, the list is prescanned to see if PREDICATE matches, otherwise copying is done regardless of whether there is a match in LIST or not; this mimics the behavior of CL:MAPCAR and is better for very short lists.

This function depends on the following contract with the caller:

1. The input LIST is immutable after any call to APPLY-TO-LIST until
the end of the program.

2. The returned LIST is likewise immutable.

The memory savings offered by this function comes at two costs: The first is the subsequent immutability of the input data, and the second is an increase in functional complexity. Specifically, while CL:MAPCAR is O(N) for a given list, FPROG:APPLY-TO-LIST – when used to implement a sharing form of MAPCAR, such as FPROG:MAPCAR-IF – has complexity O(N) in the best case, and O(2N) in the worst case when LOOKAHEAD is T, otherwise it is also O(N) (where an element to be substituted occurs at the very end of the list).

Now, the cost of speed in the worst case can lead to dramatic improvements in memory usage in the average case, with an attendant speed advantage. Take the case of a list which is 500 elements long. In my environment, here are the timings for using MAPCAR to generate a new list from an old one where only one cons cell needs to be changed. These times were determined by calling the same code repeatedly 1,000,000 times (that code is near the end of this file, in the function TIMING-TESTS):

Evaluation took:
8.367 seconds of real time
7.931782 seconds of user run time
0.342331 seconds of system run time
[Run times include 2.679 seconds GC run time.]
0 calls to %EVAL
0 page faults and
4,024,029,056 bytes consed.

That’s 4 gigabytes of memory, probably to be expected. The only reason this doesn’t blow the heap is because all of the intermediate results are being thrown away, making a lot of the cons’ing "free". If the results are kept, the MAPCAR solution becomes impossible without dramatically increasing Lisp’s heap size.

The memory and time costs of using MAPCAR in this example are constant no matter whether the cons cell is substituted at the beginning, middle or end of the 500 element list. To compare, here are the time and memory statistics from FPROG:MAPCAR-IF for the same data, in all three cases (best, average, worst):

Evaluation took:
3.478 seconds of real time
3.474324 seconds of user run time
0.003887 seconds of system run time
[Run times include 0.026 seconds GC run time.]
0 calls to %EVAL
0 page faults and
40,007,952 bytes consed.

In the best case, memory usage is reduced by two orders of magnitude, with an appreciable boost in speed. If the results of this case are saved (using COLLECT in the LOOP instead of DO), the speed savings can become dramatic. Note also that except for the immutability constraints, the results from the two different approaches are EQUAL.

Evaluation took:
7.495 seconds of real time
7.272269 seconds of user run time
0.173947 seconds of system run time
[Run times include 1.416 seconds GC run time.]
0 calls to %EVAL
0 page faults and
2,032,015,008 bytes consed.

In the average case (middle of the list), memory usage is cut in half, while runtime speed is still faster. The cons’ing of CL:MAPCAR also gets more expensive the more the results are kept, so this trivial speed tests – where no results are saved – is not exactly fair between the two. But even still FPROG:MAPCAR-IF is doing well.

Evaluation took:
11.343 seconds of real time
10.969349 seconds of user run time
0.327477 seconds of system run time
[Run times include 2.679 seconds GC run time.]
0 calls to %EVAL
0 page faults and
4,024,030,568 bytes consed.

Finally, the pathological case, where MAPCAR-IF degenerates into an exact duplicate of MAPCAR. Memory use is the same, but speed is much slower because the call to MEMBER-IF is searching the entire list before we decide that all of it needs duplication.

Below are possible FUNCTION arguments relating to the three canonical uses of APPLY-TO-LIST, plus the names of provided convenience functions which offer simple implementations of them:

1. Modify an existing element: #’(lambda (list) (cons new-cons (cdr list)))

Use: (FPROG:MAPCAR-IF predicate function list)

2. Remove an existing element: #’(lambda (list) (cdr list))

Use: (FPROG:REMOVE-IF predicate list)

3. Add a new element: #’(lambda (list) (cons new-cons list))

Use: (FPROG:INSERT-IF predicate function list)

Note: When removing elements, SKIP-TO-NEXT must be set to NIL, otherwise further matching elements might be missed. For modifying and adding elements, SKIP-TO-NEXT is likely to always be T (the default).

The functionality offered by APPLY-TO-LIST is that every cons cell from the original LIST, after the last matching member, is shared entirely. This is quite different from COPY-LIST, which creates new cons cells for every position – even those that do not require a unique structure. For example, consider the following list:

(defparameter *alist* ’((a . 1) (b . 2) (e . 3) (f . 6) (g . 7)))

The idea is to return another version of this immutable list, while sharing as much structure as possible – because the return value is also considered immutable. The following function call achieves this, using the Modify pattern from above:

(apply-to-list *alist* #’(lambda (member) (eq ’e (car member))) #’(lambda (list) (cons (cons (caar list) 5)
(cdr list))))
=> ’((a . 1) (b . 2) (e . 5) (f . 6) (g . 7))

In the returned list, 15 atoms are shared with the original, while one new cons cell and one new atom are created:

1, 2, 3: (a . 1)
4, 5, 6: (b . 2)
7: e
8, 9, 10 11: ((f . 6) ...)
12, 13, 14, 15: ((g . 7))

The usual practice of calling MAPCAR and changing the incorrect element would have result in sharing only 13 atoms. That code might have looked like this:

(mapcar #’(lambda (cell)
(if (eq ’e (car cell))
(cons (car cell) 5)
cell)) *alist*)

Further, while a discrepancy of 2 cons cells may not seem like much in this example, the difference increases by one for every cell beyond the cell that matches. Thus, if the input list had contained 100 cells beyond (e . 3), the difference would have been 102 cells, and not merely 2.

Finally, in our example exactly 4 new cons cells and 1 new atom were created as a result of the call:

1: ((a . 1) ...)
2: ((b . 2) ...)
3: ((e . 5) ...)
4: (e . 5)
5: 5

This is the minimum amount of new information required to represent a new structure where the only change is that ’e’ is paired with 5 instead of 3.

The idea of APPLY-TO-LIST is to support efficient functional programming, whereat immutable outputs are derived from immutable inputs by efficiently sharing as much structure as possible – resulting in the least new memory allocated. In cases where no references are held, this offers little gain over advanced generational garbage collection (such as lists passed within a recursive function); but where the results are held over the longer term, such as a series of computed values stored in a results list, the savings of this function can become substantial. It was exactly this kind of sitation that motivated APPLY-TO-LIST: it made it possible to reduce overall memory consumption by a factor of 20, without introducing any additional complexity into the calling code.

Package
Source

fprog.lisp (file)

Macro: pushend ITEM THE-LIST &optional FINAL-CONS
Package
Source

cambl.lisp (file)

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

#### 5.1.3 Functions

Function: amount STRING &key POOL
Package
Source

cambl.lisp (file)

Function: amount* STRING &key POOL
Package
Source

cambl.lisp (file)

Function: amount-commodity INSTANCE
Function: (setf amount-commodity) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: amount-in-balance BALANCE COMMODITY
Package
Source

cambl.lisp (file)

Function: amount-keep-precision-p INSTANCE
Function: (setf amount-keep-precision-p) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: amount-p OBJECT
Package
Source

cambl.lisp (file)

Function: amount-quantity INSTANCE
Function: (setf amount-quantity) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: annotated-commodity-p OBJECT
Package
Source

cambl.lisp (file)

Function: annotation-date INSTANCE
Function: (setf annotation-date) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: annotation-price INSTANCE
Function: (setf annotation-price) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: annotation-tag INSTANCE
Function: (setf annotation-tag) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: balance-amounts BALANCE
Package
Source

cambl.lisp (file)

Function: balance-commodities BALANCE
Package
Source

cambl.lisp (file)

Function: balance-commodity-count BALANCE
Package
Source

cambl.lisp (file)

Function: balance-first-amount BALANCE
Package
Source

cambl.lisp (file)

Function: balance-p OBJECT
Package
Source

cambl.lisp (file)

Function: commodity-builtin-p COMM
Package
Source

cambl.lisp (file)

Setf Expander

(setf commodity-builtin-p) (setf expander)

Setf Expander: (setf commodity-builtin-p) COMM
Package
Source

cambl.lisp (file)

commodity-builtin-p (function)

Function: commodity-equal A B

Two commodities are EQUAL if they are the same object.

Package
Source

cambl.lisp (file)

Function: commodity-equalp A B
Package
Source

cambl.lisp (file)

Function: commodity-european-style-p COMM
Package
Source

cambl.lisp (file)

Setf Expander

(setf commodity-european-style-p) (setf expander)

Setf Expander: (setf commodity-european-style-p) COMM
Package
Source

cambl.lisp (file)

commodity-european-style-p (function)

Function: commodity-lessp LEFT RIGHT

Return T if commodity LEFT should be sorted before RIGHT.

Package
Source

cambl.lisp (file)

Function: commodity-no-market-price-p COMM
Package
Source

cambl.lisp (file)

Setf Expander

(setf commodity-no-market-price-p) (setf expander)

Setf Expander: (setf commodity-no-market-price-p) COMM
Package
Source

cambl.lisp (file)

commodity-no-market-price-p (function)

Function: commodity-pool COMM
Package
Source

cambl.lisp (file)

Setf Expander

(setf commodity-pool) (setf expander)

Setf Expander: (setf commodity-pool) COMM
Package
Source

cambl.lisp (file)

commodity-pool (function)

Function: commodity-price-history COMM
Package
Source

cambl.lisp (file)

Setf Expander

(setf commodity-price-history) (setf expander)

Setf Expander: (setf commodity-price-history) COMM
Package
Source

cambl.lisp (file)

commodity-price-history (function)

Function: commodity-thousand-marks-p COMM
Package
Source

cambl.lisp (file)

Setf Expander

(setf commodity-thousand-marks-p) (setf expander)

Setf Expander: (setf commodity-thousand-marks-p) COMM
Package
Source

cambl.lisp (file)

commodity-thousand-marks-p (function)

Function: compare-amounts-visually LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: exact-amount STRING &key POOL
Package
Source

cambl.lisp (file)

Function: exchange-commodity AMOUNT &key TOTAL-COST PER-UNIT-COST MOMENT TAG
Package
Source

cambl.lisp (file)

Function: find-annotated-commodity NAME-OR-COMMODITY DETAILS &key CREATE-IF-NOT-EXISTS-P POOL

Find an annotated commodity matching the commodity symbol NAME, which may be a STRING or a COMMODITY-SYMBOL, and given set of commodity DETAILS, of type COMMODITY-ANNOTATION.

Returns two values: COMMODITY or NIL, NEWLY-CREATED-P

Package
Source

cambl.lisp (file)

Function: find-commodity NAME &key CREATE-IF-NOT-EXISTS-P POOL

Find a COMMODITY identifier by the symbol name found by parsing NAME.

The NAME can be either a string or an input stream, or nil, in which case the name is read from *STANDARD-INPUT*.

The argument :POOL specifies the commodity pool which will maintain this commodity, and by which other code may access it again.

The argument :CREATE-IF-NOT-EXISTS-P indicates whether a new commodity should be created if one cannot already be found.

The return values are: COMMODITY or NIL, NEWLY-CREATED-P

Package
Source

cambl.lisp (file)

Function: get-amounts-map INSTANCE
Function: (setf get-amounts-map) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: insert-if PREDICATE FUNCTION LIST
Package
Source

fprog.lisp (file)

Function: make-commodity-annotation &key (PRICE PRICE) (DATE DATE) (TAG TAG)
Package
Source

cambl.lisp (file)

Function: make-commodity-pool &key (BY-NAME-MAP BY-NAME-MAP) (DEFAULT-COMMODITY DEFAULT-COMMODITY)
Package
Source

cambl.lisp (file)

Function: mapcar-if PREDICATE FUNCTION LIST
Package
Source

fprog.lisp (file)

Function: parse-amount &rest ARGS
Package
Source

cambl.lisp (file)

Function: parse-amount* &rest ARGS
Package
Source

cambl.lisp (file)

Function: read-amount IN &key OBSERVE-PROPERTIES-P POOL

Parse an AMOUNT from the input stream IN.

If :OBSERVE-PROPERTIES-P is T (the default), any display details noticed in this amount will be set as defaults for displaying this kind of commodity in the future.

If :POOL is set, any commodities created by this routine (a maximum possible of two, if an annotated price is given with a second commodity) will be associated with the given commodity pool.

The possible syntax for an amount is:

[-]NUM[ ]SYM [ANNOTATION]
SYM[ ][-]NUM [ANNOTATION]

Package
Source

cambl.lisp (file)

Package
Source

cambl.lisp (file)

Package
Source

cambl.lisp (file)

Function: remove-if PREDICATE LIST
Package
Source

fprog.lisp (file)

Function: reset-commodity-pool &optional POOL
Package
Source

cambl.lisp (file)

Function: sign AMOUNT

Return -1, 0 or 1 depending on the sign of AMOUNT.

Package
Source

cambl.lisp (file)

Function: sign* AMOUNT

Return -1, 0 or 1 depending on the sign of AMOUNT.

Package
Source

cambl.lisp (file)

Function: value-greatereqp LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value-greatereqp* LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value-greaterp LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value-greaterp* LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value-lesseqp LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value-lesseqp* LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value-lessp LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value-lessp* LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value-maybe-round AMOUNT
Package
Source

cambl.lisp (file)

Function: value-round AMOUNT &optional PRECISION

Round the given AMOUNT to the stated PRECISION.

If PRECISION is less than the current internal precision, data will be lost. If it is greater, this operation has no effect.

Package
Source

cambl.lisp (file)

Function: value< LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value<= LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value> LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: value>= LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: valuep OBJECT
Package
Source

cambl.lisp (file)

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

#### 5.1.4 Generic functions

Package
Source

cambl.lisp (file)

Methods
Method: add (LEFT balance) (RIGHT balance)
Method: add (LEFT balance) (RIGHT amount)
Method: add (LEFT balance) (RIGHT rational)
Method: add (LEFT amount) (RIGHT balance)
Method: add (LEFT amount) (RIGHT amount)
Method: add (LEFT amount) (RIGHT rational)
Method: add (LEFT rational) (RIGHT balance)
Method: add (LEFT rational) (RIGHT amount)
Method: add (LEFT rational) (RIGHT rational)
Generic Function: amount-precision ITEM
Package
Source

cambl.lisp (file)

Methods
Method: amount-precision (ITEM amount)
Method: amount-precision (ITEM rational)
Generic Function: annotate-commodity ITEM ANNOTATION
Package
Source

cambl.lisp (file)

Methods
Method: annotate-commodity (AMOUNT amount) (DETAILS commodity-annotation)
Method: annotate-commodity (COMMODITY commodity) (DETAILS commodity-annotation)
Generic Function: commodity-annotation ITEM
Package
Source

cambl.lisp (file)

Methods
Method: commodity-annotation (AMOUNT amount)
Method: commodity-annotation (ANNOTATED-COMMODITY annotated-commodity)
Method: commodity-annotation (COMMODITY commodity)
Generic Function: commodity-annotation-equal LEFT-ITEM RIGHT-ITEM
Package
Source

cambl.lisp (file)

Methods
Method: commodity-annotation-equal (A commodity-annotation) (B commodity-annotation)
Generic Function: commodity-name ITEM &optional NO-ANNOTATION
Package
Source

cambl.lisp (file)

Methods
Method: commodity-name (AMOUNT amount) &optional NO-ANNOTATION
Method: commodity-name (COMMODITY commodity) &optional NO-ANNOTATION
Method: commodity-name (NULL null) &optional NO-ANNOTATION
Generic Function: commodity-qualified-name OBJECT
Generic Function: (setf commodity-qualified-name) NEW-VALUE OBJECT
Package
Methods
Method: commodity-qualified-name (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf commodity-qualified-name) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: compare LEFT RIGHT
Package
Source

cambl.lisp (file)

Methods
Method: compare (LEFT amount) (RIGHT amount)
Method: compare (LEFT rational) (RIGHT amount)
Method: compare (LEFT amount) (RIGHT rational)
Method: compare (LEFT rational) (RIGHT rational)
Generic Function: compare* LEFT RIGHT
Package
Source

cambl.lisp (file)

Methods
Method: compare* (LEFT amount) (RIGHT amount)
Method: compare* (LEFT rational) (RIGHT amount)
Method: compare* (LEFT amount) (RIGHT rational)
Method: compare* (LEFT rational) (RIGHT rational)
Generic Function: display-precision ITEM
Package
Source

cambl.lisp (file)

Methods
Method: display-precision (AMOUNT amount)
Method: display-precision (ANNOTATED-COMMODITY annotated-commodity)
Method: display-precision (COMMODITY commodity)
Generic Function: divide VALUE-A VALUE-B
Package
Source

cambl.lisp (file)

Methods
Method: divide (LEFT balance) (RIGHT amount)
Method: divide (LEFT balance) (RIGHT rational)
Method: divide (LEFT amount) (RIGHT amount)
Method: divide (LEFT amount) (RIGHT rational)
Method: divide (LEFT rational) (RIGHT balance)
Method: divide (LEFT rational) (RIGHT amount)
Method: divide (LEFT rational) (RIGHT rational)
Generic Function: format-value VALUE &key OMIT-COMMODITY-P FULL-PRECISION-P WIDTH LATTER-WIDTH LINE-FEED-STRING
Package
Source

cambl.lisp (file)

Methods
Method: format-value (BALANCE balance) &key OMIT-COMMODITY-P FULL-PRECISION-P WIDTH LATTER-WIDTH LINE-FEED-STRING
Method: format-value (AMOUNT amount) &key OMIT-COMMODITY-P FULL-PRECISION-P WIDTH LATTER-WIDTH LINE-FEED-STRING
Method: format-value (RATIONAL rational) &key OMIT-COMMODITY-P FULL-PRECISION-P WIDTH LATTER-WIDTH LINE-FEED-STRING
Generic Function: market-value ANY-ITEM &optional FIXED-TIME
Package
Source

cambl.lisp (file)

Methods
Method: market-value (BALANCE balance) &optional FIXED-TIME
Method: market-value (AMOUNT amount) &optional FIXED-TIME
Method: market-value (RATIONAL rational) &optional FIXED-TIME
Method: market-value (ANNOTATED-COMMODITY annotated-commodity) &optional FIXED-TIME
Method: market-value (COMMODITY commodity) &optional FIXED-TIME
Generic Function: multiply VALUE-A VALUE-B
Package
Source

cambl.lisp (file)

Methods
Method: multiply (LEFT balance) (RIGHT amount)
Method: multiply (LEFT balance) (RIGHT rational)
Method: multiply (LEFT amount) (RIGHT amount)
Method: multiply (LEFT amount) (RIGHT rational)
Method: multiply (LEFT rational) (RIGHT balance)
Method: multiply (LEFT rational) (RIGHT amount)
Method: multiply (LEFT rational) (RIGHT rational)
Generic Function: negate VALUE
Package
Source

cambl.lisp (file)

Methods
Method: negate (BALANCE balance)
Method: negate (AMOUNT amount)
Method: negate (RATIONAL rational)
Generic Function: print-value VALUE &key OUTPUT-STREAM OMIT-COMMODITY-P FULL-PRECISION-P WIDTH LATTER-WIDTH LINE-FEED-STRING
Package
Source

cambl.lisp (file)

Methods
Method: print-value (BALANCE balance) &key OUTPUT-STREAM OMIT-COMMODITY-P FULL-PRECISION-P WIDTH LATTER-WIDTH LINE-FEED-STRING
Method: print-value (AMOUNT amount) &key OUTPUT-STREAM OMIT-COMMODITY-P FULL-PRECISION-P WIDTH LATTER-WIDTH LINE-FEED-STRING
Method: print-value (RATIONAL rational) &key OUTPUT-STREAM OMIT-COMMODITY-P FULL-PRECISION-P WIDTH LATTER-WIDTH LINE-FEED-STRING
Method: print-value (INTEGER integer) &key OUTPUT-STREAM OMIT-COMMODITY-P FULL-PRECISION-P WIDTH LATTER-WIDTH LINE-FEED-STRING
Generic Function: strip-annotations ANY-ITEM &key KEEP-PRICE KEEP-DATE KEEP-TAG
Package
Source

cambl.lisp (file)

Methods
Method: strip-annotations (BALANCE balance) &key KEEP-PRICE KEEP-DATE KEEP-TAG
Method: strip-annotations (AMOUNT amount) &key KEEP-PRICE KEEP-DATE KEEP-TAG
Method: strip-annotations (RATIONAL rational) &key KEEP-PRICE KEEP-DATE KEEP-TAG
Method: strip-annotations (ANNOTATED-COMMODITY annotated-commodity) &key KEEP-PRICE KEEP-DATE KEEP-TAG
Method: strip-annotations (COMMODITY commodity) &key KEEP-PRICE KEEP-DATE KEEP-TAG
Generic Function: subtract VALUE-A VALUE-B
Package
Source

cambl.lisp (file)

Methods
Method: subtract (LEFT balance) (RIGHT balance)
Method: subtract (LEFT balance) (RIGHT amount)
Method: subtract (LEFT balance) (RIGHT rational)
Method: subtract (LEFT amount) (RIGHT balance)
Method: subtract (LEFT amount) (RIGHT amount)
Method: subtract (LEFT amount) (RIGHT rational)
Method: subtract (LEFT rational) (RIGHT balance)
Method: subtract (LEFT rational) (RIGHT amount)
Method: subtract (LEFT rational) (RIGHT rational)
Generic Function: value-abs VALUE
Package
Source

cambl.lisp (file)

Methods
Method: value-abs (BALANCE balance)
Method: value-abs (AMOUNT amount)
Method: value-abs (RATIONAL rational)
Generic Function: value-equal LEFT RIGHT
Package
Source

cambl.lisp (file)

Methods
Method: value-equal (LEFT balance) (RIGHT balance)
Method: value-equal (LEFT balance) (RIGHT amount)
Method: value-equal (LEFT balance) (RIGHT rational)
Method: value-equal (LEFT amount) (RIGHT balance)
Method: value-equal (LEFT amount) (RIGHT amount)
Method: value-equal (LEFT amount) (RIGHT rational)
Method: value-equal (LEFT rational) (RIGHT balance)
Method: value-equal (LEFT rational) (RIGHT amount)
Method: value-equal (LEFT rational) (RIGHT rational)
Generic Function: value-equalp LEFT RIGHT
Package
Source

cambl.lisp (file)

Methods
Method: value-equalp (LEFT balance) (RIGHT balance)
Method: value-equalp (LEFT balance) (RIGHT amount)
Method: value-equalp (LEFT balance) (RIGHT rational)
Method: value-equalp (LEFT amount) (RIGHT balance)
Method: value-equalp (LEFT amount) (RIGHT amount)
Method: value-equalp (LEFT amount) (RIGHT rational)
Method: value-equalp (LEFT rational) (RIGHT balance)
Method: value-equalp (LEFT rational) (RIGHT amount)
Method: value-equalp (LEFT rational) (RIGHT rational)
Generic Function: value-minusp VALUE
Package
Source

cambl.lisp (file)

Methods
Method: value-minusp (BALANCE balance)
Method: value-minusp (AMOUNT amount)
Method: value-minusp (RATIONAL rational)
Generic Function: value-minusp* VALUE
Package
Source

cambl.lisp (file)

Methods
Method: value-minusp* (BALANCE balance)
Method: value-minusp* (AMOUNT amount)
Method: value-minusp* (RATIONAL rational)
Generic Function: value-not-equal LEFT RIGHT
Package
Source

cambl.lisp (file)

Methods
Method: value-not-equal (LEFT balance) (RIGHT balance)
Method: value-not-equal (LEFT balance) (RIGHT amount)
Method: value-not-equal (LEFT balance) (RIGHT rational)
Method: value-not-equal (LEFT amount) (RIGHT balance)
Method: value-not-equal (LEFT amount) (RIGHT amount)
Method: value-not-equal (LEFT amount) (RIGHT rational)
Method: value-not-equal (LEFT rational) (RIGHT balance)
Method: value-not-equal (LEFT rational) (RIGHT amount)
Method: value-not-equal (LEFT rational) (RIGHT rational)
Generic Function: value-not-equalp LEFT RIGHT
Package
Source

cambl.lisp (file)

Methods
Method: value-not-equalp (LEFT balance) (RIGHT balance)
Method: value-not-equalp (LEFT balance) (RIGHT amount)
Method: value-not-equalp (LEFT balance) (RIGHT rational)
Method: value-not-equalp (LEFT amount) (RIGHT balance)
Method: value-not-equalp (LEFT amount) (RIGHT amount)
Method: value-not-equalp (LEFT amount) (RIGHT rational)
Method: value-not-equalp (LEFT rational) (RIGHT balance)
Method: value-not-equalp (LEFT rational) (RIGHT amount)
Method: value-not-equalp (LEFT rational) (RIGHT rational)
Generic Function: value-plusp VALUE
Package
Source

cambl.lisp (file)

Methods
Method: value-plusp (BALANCE balance)
Method: value-plusp (AMOUNT amount)
Method: value-plusp (RATIONAL rational)
Generic Function: value-plusp* VALUE
Package
Source

cambl.lisp (file)

Methods
Method: value-plusp* (BALANCE balance)
Method: value-plusp* (AMOUNT amount)
Method: value-plusp* (RATIONAL rational)
Generic Function: value-zerop VALUE
Package
Source

cambl.lisp (file)

Methods
Method: value-zerop (BALANCE balance)
Method: value-zerop (AMOUNT amount)
Method: value-zerop (RATIONAL rational)
Generic Function: value-zerop* VALUE
Package
Source

cambl.lisp (file)

Methods
Method: value-zerop* (BALANCE balance)
Method: value-zerop* (AMOUNT amount)
Method: value-zerop* (RATIONAL rational)
Generic Function: value/= LEFT RIGHT
Package
Source

cambl.lisp (file)

Methods
Method: value/= (LEFT balance) (RIGHT balance)
Method: value/= (LEFT balance) (RIGHT amount)
Method: value/= (LEFT balance) (RIGHT rational)
Method: value/= (LEFT amount) (RIGHT balance)
Method: value/= (LEFT amount) (RIGHT amount)
Method: value/= (LEFT amount) (RIGHT rational)
Method: value/= (LEFT rational) (RIGHT balance)
Method: value/= (LEFT rational) (RIGHT amount)
Method: value/= (LEFT rational) (RIGHT rational)
Generic Function: value= LEFT RIGHT
Package
Source

cambl.lisp (file)

Methods
Method: value= (LEFT balance) (RIGHT balance)
Method: value= (LEFT balance) (RIGHT amount)
Method: value= (LEFT balance) (RIGHT rational)
Method: value= (LEFT amount) (RIGHT balance)
Method: value= (LEFT amount) (RIGHT amount)
Method: value= (LEFT amount) (RIGHT rational)
Method: value= (LEFT rational) (RIGHT balance)
Method: value= (LEFT rational) (RIGHT amount)
Method: value= (LEFT rational) (RIGHT rational)

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

#### 5.1.5 Conditions

Condition: amount-error ()
Package
Source

cambl.lisp (file)

Direct superclasses

error (condition)

Direct methods
Direct slots
Slot: description
Initargs

:msg

error-description (generic function)

Slot: operands
Initargs

:operands

error-operands (generic function)

Condition: commodity-error ()
Package
Source

cambl.lisp (file)

Direct superclasses

error (condition)

Direct methods
Direct slots
Slot: description
Initargs

:msg

error-description (generic function)

Slot: commodity
Initargs

:commodity

Initform

(quote nil)

error-commodity (generic function)

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

#### 5.1.6 Structures

Structure: amount ()
Package
Source

cambl.lisp (file)

Direct superclasses

structure-object (structure)

Direct methods
Direct slots
Slot: commodity
Type

(or cambl::commodity null)

amount-commodity (function)

Writers

(setf amount-commodity) (function)

Slot: quantity
Type

rational

Initform

0

amount-quantity (function)

Writers

(setf amount-quantity) (function)

Slot: full-precision
Type

cambl::fixnum+

Initform

0

amount-full-precision (function)

Writers

(setf amount-full-precision) (function)

Slot: keep-precision-p
Type

boolean

amount-keep-precision-p (function)

Writers

(setf amount-keep-precision-p) (function)

Structure: commodity-annotation ()
Package
Source

cambl.lisp (file)

Direct superclasses

structure-object (structure)

Direct methods
Direct slots
Slot: price

annotation-price (function)

Writers

(setf annotation-price) (function)

Slot: date
Type

(or periods:fixed-time null)

annotation-date (function)

Writers

(setf annotation-date) (function)

Slot: tag
Type

(or string null)

annotation-tag (function)

Writers

(setf annotation-tag) (function)

Structure: commodity-pool ()
Package
Source

cambl.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: by-name-map
Type

hash-table

Initform

(make-hash-table :test (quote equal))

commodity-pool-by-name-map (function)

Writers

(setf commodity-pool-by-name-map) (function)

Slot: default-commodity

commodity-pool-default-commodity (function)

Writers

(setf commodity-pool-default-commodity) (function)

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

#### 5.1.7 Classes

Class: annotated-commodity ()
Package
Source

cambl.lisp (file)

Direct superclasses

commodity (class)

Direct methods
Direct slots
Slot: referent
Type

cambl::commodity

Initargs

:referent

get-referent (generic function)

Writers

(setf get-referent) (generic function)

Slot: annotation
Type

cambl:commodity-annotation

Initargs

:annotation

get-commodity-annotation (generic function)

Writers

(setf get-commodity-annotation) (generic function)

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

#### 5.1.8 Types

Type: value ()
Package
Source

cambl.lisp (file)

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

### 5.2 Internal definitions

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

#### 5.2.1 Special variables

Special Variable: *invalid-symbol-chars*

The invalid commodity symbol characters are:

Space Tab Newline Return
0-9 . , ; - + * / ^ ? : & | ! = "
< > { } [ ] ( ) @

Package
Source

cambl.lisp (file)

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

#### 5.2.2 Macros

Macro: define-commodity-accessor FUNCTION ACCESSOR
Package
Source

cambl.lisp (file)

Macro: transform-balance BALANCE PREDICATE FUNCTION &key FIRST-ONLY SKIP-TO-NEXT LOOKAHEAD
Package
Source

cambl.lisp (file)

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

#### 5.2.3 Functions

Function: add-price COMMODITY PRICE &optional FIXED-TIME
Package
Source

cambl.lisp (file)

Function: amount-full-precision INSTANCE
Function: (setf amount-full-precision) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: apply-between-amounts LEFT RIGHT FUNCTION &optional ADJUSTOR
Package
Source

cambl.lisp (file)

Function: apply-between-balances LEFT RIGHT FUNCTION &optional ADJUSTOR
Package
Source

cambl.lisp (file)

Function: apply-to-balance BALANCE COMMODITY VALUE FUNCTION &optional ADJUSTOR
Package
Source

cambl.lisp (file)

Function: balance &rest AMOUNTS
Package
Source

cambl.lisp (file)

Function: balance-equal LEFT RIGHT TEST-FUNC
Package
Source

cambl.lisp (file)

Function: balance-helper LEFT RIGHT
Package
Source

cambl.lisp (file)

Function: commodity-annotation-p OBJECT
Package
Source

cambl.lisp (file)

Function: commodity-comment COMM
Package
Source

cambl.lisp (file)

Setf Expander

(setf commodity-comment) (setf expander)

Setf Expander: (setf commodity-comment) COMM
Package
Source

cambl.lisp (file)

commodity-comment (function)

Function: commodity-description COMM
Package
Source

cambl.lisp (file)

Setf Expander

(setf commodity-description) (setf expander)

Setf Expander: (setf commodity-description) COMM
Package
Source

cambl.lisp (file)

commodity-description (function)

Function: commodity-pool-by-name-map INSTANCE
Function: (setf commodity-pool-by-name-map) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: commodity-pool-default-commodity INSTANCE
Function: (setf commodity-pool-default-commodity) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: commodity-pool-p OBJECT
Package
Source

cambl.lisp (file)

Function: commodity-symbol COMM
Package
Source

cambl.lisp (file)

Setf Expander

(setf commodity-symbol) (setf expander)

Setf Expander: (setf commodity-symbol) COMM
Package
Source

cambl.lisp (file)

commodity-symbol (function)

Function: commodity-symbol-connected-p INSTANCE
Function: (setf commodity-symbol-connected-p) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: commodity-symbol-name INSTANCE
Function: (setf commodity-symbol-name) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: commodity-symbol-needs-quoting-p INSTANCE
Function: (setf commodity-symbol-needs-quoting-p) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: commodity-symbol-p OBJECT
Package
Source

cambl.lisp (file)

Function: commodity-symbol-prefixed-p INSTANCE
Function: (setf commodity-symbol-prefixed-p) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: copy-amount INSTANCE
Package
Source

cambl.lisp (file)

Function: copy-balance INSTANCE
Package
Source

cambl.lisp (file)

Function: copy-commodity-annotation INSTANCE
Package
Source

cambl.lisp (file)

Function: copy-commodity-pool INSTANCE
Package
Source

cambl.lisp (file)

Function: copy-commodity-symbol INSTANCE
Package
Source

cambl.lisp (file)

Function: copy-pricing-entry INSTANCE
Package
Source

cambl.lisp (file)

Function: create-annotated-commodity COMMODITY DETAILS QUALIFIED-NAME

Create an ANNOTATED-COMMODITY which annotates COMMODITY.

The NAME can be either a string or a COMMODITY-SYMBOL.

Package
Source

cambl.lisp (file)

Function: create-commodity NAME &key POOL

Create a COMMODITY after the symbol name found by parsing NAME.

The NAME can be either a string or an input stream, or nil, in which case the name is read from *STANDARD-INPUT*.

The argument :pool specifies the commodity pool which will maintain this commodity, and by which other code may access it again. The resulting COMMODITY object is returned.

Package
Source

cambl.lisp (file)

Function: divide-in-balance BALANCE COMMODITY VALUE
Package
Source

cambl.lisp (file)

Function: find-nearest HISTORY FIXED-TIME
Package
Source

cambl.lisp (file)

Function: format-commodity-annotation ANNOTATION &key OUTPUT-STREAM

Return the canonical annotation string for ANNOTATION.

A fully annotated commodity always follows the form:

[-]SYMBOL <VALUE> {PRICE} [DATE] (TAG)
or
<VALUE> SYMBOL {PRICE} [DATE] (TAG)

If a particular annotation is not present, those sections is simply dropped from the string, for example:

<VALUE> SYMBOL {PRICE}

Package
Source

cambl.lisp (file)

Function: make-amount &key (COMMODITY COMMODITY) (QUANTITY QUANTITY) (FULL-PRECISION FULL-PRECISION) (KEEP-PRECISION-P KEEP-PRECISION-P)
Package
Source

cambl.lisp (file)

Function: make-balance &key (AMOUNTS-MAP AMOUNTS-MAP)
Package
Source

cambl.lisp (file)

Function: make-commodity-symbol &key (NAME NAME) (NEEDS-QUOTING-P NEEDS-QUOTING-P) (PREFIXED-P PREFIXED-P) (CONNECTED-P CONNECTED-P)
Package
Source

cambl.lisp (file)

Function: make-pricing-entry &key (MOMENT MOMENT) (PRICE PRICE)
Package
Source

cambl.lisp (file)

Function: make-qualified-name COMMODITY COMMODITY-ANNOTATION
Package
Source

cambl.lisp (file)

Function: multiply-in-balance BALANCE COMMODITY VALUE
Package
Source

cambl.lisp (file)

Function: peek-char-in-line IN &optional SKIP-WHITESPACE
Package
Source

cambl.lisp (file)

Function: pricing-entry-moment INSTANCE
Function: (setf pricing-entry-moment) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: pricing-entry-p OBJECT
Package
Source

cambl.lisp (file)

Function: pricing-entry-price INSTANCE
Function: (setf pricing-entry-price) VALUE INSTANCE
Package
Source

cambl.lisp (file)

Function: print-amount AMOUNT STREAM DEPTH
Package
Source

cambl.lisp (file)

Function: print-balance BALANCE STREAM DEPTH
Package
Source

cambl.lisp (file)

Function: print-value-to-string COMMODITY COMMODITY-SYMBOL QUANTITY PRECISION OUTPUT-STREAM
Package
Source

cambl.lisp (file)

Package
Source

cambl.lisp (file)

Package
Source

cambl.lisp (file)

Parse a commodity symbol from the input stream IN.

This is the correct entry point for creating a new commodity symbol.

A commodity contain any character not found in *INVALID-SYMBOL-CHARS*. To include such characters in a symbol name—except for #\", which may never appear in a symbol name—surround the commodity name with double quotes. It is an error if EOF is reached without reading the ending double quote. If the symbol name is not quoted, and an invalid character is reading, reading from the stream stops and the invalid character is put back.

Package
Source

cambl.lisp (file)

Function: read-until IN CHAR &optional ERROR-MESSAGE
Package
Source

cambl.lisp (file)

Function: remove-price COMMODITY FIXED-TIME
Package
Source

cambl.lisp (file)

Function: symbol-char-invalid-p C
Package
Source

cambl.lisp (file)

Function: symbol-name-needs-quoting-p NAME

Return T if the given symbol NAME requires quoting.

Package
Source

cambl.lisp (file)

Function: timing-tests &optional LOOP-COUNT
Package
Source

fprog.lisp (file)

Function: verify-amounts LEFT RIGHT CAPITALIZED-GERUND
Package
Source

cambl.lisp (file)

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

#### 5.2.4 Generic functions

Generic Function: commodity-annotation-empty-p ITEM
Package
Source

cambl.lisp (file)

Methods
Method: commodity-annotation-empty-p (ANNOTATION commodity-annotation)
Generic Function: error-commodity CONDITION
Package
Methods
Method: error-commodity (CONDITION commodity-error)
Source

cambl.lisp (file)

Generic Function: error-description CONDITION
Package
Methods
Method: error-description (CONDITION commodity-error)
Source

cambl.lisp (file)

Method: error-description (CONDITION amount-error)
Source

cambl.lisp (file)

Generic Function: error-operands CONDITION
Package
Methods
Method: error-operands (CONDITION amount-error)
Source

cambl.lisp (file)

Generic Function: get-builtin-p OBJECT
Generic Function: (setf get-builtin-p) NEW-VALUE OBJECT
Package
Methods
Method: get-builtin-p (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-builtin-p) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-comment OBJECT
Generic Function: (setf get-comment) NEW-VALUE OBJECT
Package
Methods
Method: get-comment (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-comment) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-commodity-annotation OBJECT
Generic Function: (setf get-commodity-annotation) NEW-VALUE OBJECT
Package
Methods
Method: get-commodity-annotation (ANNOTATED-COMMODITY annotated-commodity)

Source

cambl.lisp (file)

Method: (setf get-commodity-annotation) NEW-VALUE (ANNOTATED-COMMODITY annotated-commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-commodity-pool OBJECT
Generic Function: (setf get-commodity-pool) NEW-VALUE OBJECT
Package
Methods
Method: get-commodity-pool (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-commodity-pool) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-description OBJECT
Generic Function: (setf get-description) NEW-VALUE OBJECT
Package
Methods
Method: get-description (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-description) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-display-precision OBJECT
Generic Function: (setf get-display-precision) NEW-VALUE OBJECT
Package
Methods
Method: get-display-precision (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-display-precision) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-european-style-p OBJECT
Generic Function: (setf get-european-style-p) NEW-VALUE OBJECT
Package
Methods
Method: get-european-style-p (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-european-style-p) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-no-market-price-p OBJECT
Generic Function: (setf get-no-market-price-p) NEW-VALUE OBJECT
Package
Methods
Method: get-no-market-price-p (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-no-market-price-p) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-price-history OBJECT
Generic Function: (setf get-price-history) NEW-VALUE OBJECT
Package
Methods
Method: get-price-history (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-price-history) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-referent OBJECT
Generic Function: (setf get-referent) NEW-VALUE OBJECT
Package
Methods
Method: get-referent (ANNOTATED-COMMODITY annotated-commodity)

Source

cambl.lisp (file)

Method: (setf get-referent) NEW-VALUE (ANNOTATED-COMMODITY annotated-commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-symbol OBJECT
Generic Function: (setf get-symbol) NEW-VALUE OBJECT
Package
Methods
Method: get-symbol (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-symbol) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

Generic Function: get-thousand-marks-p OBJECT
Generic Function: (setf get-thousand-marks-p) NEW-VALUE OBJECT
Package
Methods
Method: get-thousand-marks-p (COMMODITY commodity)

Source

cambl.lisp (file)

Method: (setf get-thousand-marks-p) NEW-VALUE (COMMODITY commodity)

automatically generated writer method

Source

cambl.lisp (file)

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

#### 5.2.5 Structures

Structure: balance ()
Package
Source

cambl.lisp (file)

Direct superclasses

structure-object (structure)

Direct methods
Direct slots
Slot: amounts-map

get-amounts-map (function)

Writers

(setf get-amounts-map) (function)

Structure: commodity-symbol ()
Package
Source

cambl.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: name
Type

string

Initform

""

commodity-symbol-name (function)

Writers

(setf commodity-symbol-name) (function)

Slot: needs-quoting-p
Type

boolean

commodity-symbol-needs-quoting-p (function)

Writers

(setf commodity-symbol-needs-quoting-p) (function)

Slot: prefixed-p
Type

boolean

commodity-symbol-prefixed-p (function)

Writers

(setf commodity-symbol-prefixed-p) (function)

Slot: connected-p
Type

boolean

commodity-symbol-connected-p (function)

Writers

(setf commodity-symbol-connected-p) (function)

Structure: pricing-entry ()
Package
Source

cambl.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: moment

pricing-entry-moment (function)

Writers

(setf pricing-entry-moment) (function)

Slot: price

pricing-entry-price (function)

Writers

(setf pricing-entry-price) (function)

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

#### 5.2.6 Classes

Class: commodity ()
Package
Source

cambl.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses

annotated-commodity (class)

Direct methods
Direct slots
Slot: symbol
Initargs

:symbol

get-symbol (generic function)

Writers

(setf get-symbol) (generic function)

Slot: description
Type

(or string null)

Initargs

:description

get-description (generic function)

Writers

(setf get-description) (generic function)

Slot: comment
Type

(or string null)

Initargs

:comment

get-comment (generic function)

Writers

(setf get-comment) (generic function)

Slot: thousand-marks-p
Type

boolean

Initargs

:thousand-marks-p

get-thousand-marks-p (generic function)

Writers

(setf get-thousand-marks-p) (generic function)

Slot: european-style-p
Type

boolean

Initargs

:european-style-p

get-european-style-p (generic function)

Writers

(setf get-european-style-p) (generic function)

Slot: no-market-price-p
Type

boolean

Initargs

:no-market-price-p

get-no-market-price-p (generic function)

Writers

(setf get-no-market-price-p) (generic function)

Slot: builtin-p
Type

boolean

Initargs

:builtin-p

get-builtin-p (generic function)

Writers

(setf get-builtin-p) (generic function)

Slot: display-precision
Type

cambl::fixnum+

Initargs

:display-precision

Initform

0

get-display-precision (generic function)

Writers

(setf get-display-precision) (generic function)

Slot: price-history
Initargs

:price-history

get-price-history (generic function)

Writers

(setf get-price-history) (generic function)

Slot: commodity-pool
Type

cambl:commodity-pool

Initargs

:commodity-pool

get-commodity-pool (generic function)

Writers

(setf get-commodity-pool) (generic function)

Slot: qualified-name
Type

(or string null)

Initargs

:qualified-name

commodity-qualified-name (generic function)

Writers

(setf commodity-qualified-name) (generic function)

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

#### 5.2.7 Types

Type: fixnum+ ()
Package
Source

cambl.lisp (file)

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

## Appendix A Indexes

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

### A.1 Concepts

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

### A.2 Functions

Jump to: (   A   B   C   D   E   F   G   I   M   N   P   R   S   T   V
Jump to: (   A   B   C   D   E   F   G   I   M   N   P   R   S   T   V

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

### A.3 Variables

Jump to: *   A   B   C   D   E   F   K   M   N   O   P   Q   R   S   T
Jump to: *   A   B   C   D   E   F   K   M   N   O   P   Q   R   S   T

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