Description

Provides property list operations.

Author

Kon Lovett

Version

Usage

(require-extension proplist)

Download

proplist.egg

Documentation

Proplist is a Lisp inspired set of procedures supporting property list operations. A property list is a list of key-value pairs arranged along the top-level spine of the list.

A property list vs. an association list: PROPLIST - (key1 val1 key2 val2) ALIST - ((key1 val1) (key2 val2)).

A HANDLE may be a procedure, symbol, hash-table, or a property-list. See the proplist-extraslot and proplist-procslot parameters for Lisp-like property list attachment.

A PROPKEY can be any Scheme object, but matching depends on the proplist-equal and proplist-member parameters.

Proplist supports the pre-2.2 CHICKEN "disembodied" property list functionality, when the HANDLE is a hash-table. However, the original functions get and put! are not defined.

Property list

procedure: (proplist-procedure PROC)

Returns the extended procedure with an empty property list.

procedure: (getprop HANDLE PROPKEY [DEFAULT #f])

Returns the first property PROPKEY value of HANDLE, or the optional DEFAULT, when no such property.

procedure: (putprop! HANDLE [PROPKEY VALUE ...])

Adds the property PROPKEY value of HANDLE to the supplied VALUE. Does not replace an existing property.

procedure: (setprop! HANDLE [PROPKEY VALUE ...])

Sets the property PROPKEY value of HANDLE to the supplied VALUE. Replaces any existing property.

procedure: (remprop! HANDLE [PROPKEY ...])

Removes the first property PROPKEY of HANDLE.

procedure: (remprop/all! HANDLE [PROPKEY ...])

Removes every property PROPKEY of HANDLE.

procedure: (proplist HANDLE [PROPKEY ...])

Returns the first property PROPKEY value of HANDLE for every property key specified, as a property list. All properties returned when no key specified.

procedure: (proplist->alist HANDLE [PROPKEY ...])

Returns the first properties PROPKEY ... key-value pairs of HANDLE as an association list. All properties when no key specified.

procedure: (proplist->alist ALIST [PROPKEY ...])

Returns the first properties PROPKEY .. key-value pairs of ALIST as an asscociation list. All properties when no key specified.

Parameters

parameter: (proplist-equal [PROC eq?])

Sets or gets the binary procedure for property key equality testing. Ignored for a hash-table.

parameter: (proplist-member [PROC memq?])

Sets or gets the binary procedure for property key list membership testing. Ignored for a hash-table.

parameter: (proplist-extraslot [FLAG])

The property list is sourced from the symbol extraslot when FLAG is #t. Should the symbol extraslot feature not be available or the FLAG is #f the property list is found in a hash-table.

parameter: (proplist-procslot [FLAG])

The property list is sourced from the procedure extended data when FLAG is #t. Should the FLAG be #f the property list is found in a hash-table.

The procedure must be initialized before using as a property list handle.

Example: (define foo (proplist-procedure (lambda () #t))).

Property list I/O

Property list SRFI-10 support procedures.

A reader-ctor is defined for the external text representation of a property list.

procedure: (print-proplist HANDLE [PORT])

Writes the external text representation of the property list for HANDLE to the output PORT. Port defaults to the (current-output-port).

procedure: (set-proplist! HANDLE PROPLIST)

Sets the property list for HANDLE to the supplied PROPLIST.

Though not an I/O operation this procedure is considered too dangerous for regular use and buried in this section.

License

Copyright (c) 2005, Kon Lovett.  All rights reserved.

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 ASIS, 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.