Outdated egg!
This is an egg for CHICKEN 3, the unsupported old release. You're almost certainly looking for the CHICKEN 4 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
srfi-38
Description
A Chicken version of the reference implementation for SRFI-38, a facility for reading and writing objects with shared structure.
Author
Al Petrofsky and Ray Dillinger
Download
Documentation
See SRFI-38 document.
This implementation extends write-with-shared-structure to accept optional flags (following the optional port argument).
Passing the keyword #:ignore-strings will treat strings as normal (nonshared) objects.
The keyword #:interesting-procedures is followed by a list of three procedures:
- interesting? : (object -> boolean)
- write-interesting : ((output-port -> object) output-port object association-list -> association-list)
- scan : ((object association-list -> association-list) object association-list -> association-list)
The interesting? procedure returns #t when the object can be processed, #f otherwise.
All optional "interesting objects" are written as #<KIND-SYMBOL[OBJECT]...>. It is the job of write-interesting to display the KIND-SYMBOL and write any elements, using the first procedure, separated by #\space. Writing the elements of the object as a list or vector is advised.
The scan procedure must call the first procedure for every element of the object. The returned association-list is used for the next invocation. Returns the modified association-list.
This implementation extends read-with-shared-structure to accept optional flags (following the optional port argument).
The keyword #:interesting-procedures is followed by a list of three procedures:
- interesting? : (object -> boolean)
- read-interesting : ((-> object) input-port symbol -> object)
- scan : ((object -> unspecified) (object -> object) object -> unspecified)
The interesting? procedure returns #t when the object can be processed, #f otherwise.
The read-interesting procedure must use the first procedure to read any elements of the object. The symbol is the KIND-SYMBOL. The procedure should return #f for an unsuccessful operation, otherwise the reified object. The procedure must not consume the trailing #\> but must exit positioned at the trailing #\>. The input-port is positioned just after the KIND-SYMBOL upon invocation.
The scan procedure must call the second procedure for every element of the object when the element is a procedure, otherwise it must call the first procedure with the element.
Changelog
- 1.3 records & hash-tables are "interesting", #:interesting-procedures parameter [Kon Lovett]
- 1.2 option for ignoring sharing of strings [suggested by Sven Hartrumpf]
- 1.1 Initial release
License
Copyright (C) Ray Dillinger 2003. All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Scheme Request For Implementation process or editors, except as needed for the purpose of developing SRFIs in which case the procedures for copyrights defined in the SRFI process must be followed, or as required to translate it into languages other than English.
The limited permissions granted above are perpetual and will not be revoked by the authors or their successors or assigns.
This document and the information contained herein is provided on an "AS IS" basis and THE AUTHOR AND THE SRFI EDITORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.