From: kend@data.rain.com (Ken Dickey)
Newsgroups: comp.lang.scheme
Subject: Re: random rant on random files
Date: 16 Aug 92 03:15:25 GMT
Organization: Microtek DSD, Hillsboro, OR

vanMeule@cup.portal.COM writes:

>I feel a little upset at Scheme for lack of direct support in 
>most Schemes for random files.  These are essential for business
>programming.  Scheme should and could revolutionize business and
>supplant BASIC with all its basic flaws if Scheme provided a 
>library routine for random files that was part of the definition.
> ...
>Any comments that might help me towards my desire to be able to
>do real business programming in Scheme??? 

One reason is that random access is not supported is the desire not to
support "files" when persistent data objects are just around the
corner.  My aproach to the random access problem follows.

Enjoy!
-Ken Dickey				kend@data.rain.com
;;=====================================================================
; FILE		"store.doc"
; IMPLEMENTS	Proposal for a `Store' data abstraction.
; AUTHOR	Ken Dickey
; DATE		1991 November 26
; LAST UPDATED	1991 December 12 -- added WRITE-STORE-SLICE


PRIMARY REASON DE ETRA:  Random & Binary i/o.

BASIC IDEA: A (binary) store with size and permissions.

NOTA BENE:  This data type has no print representation.


SYNOPSIS:

(MAKE-STORE num-bytes . fill-integer) -> store
(MAKE-STORE num-bytes fill-integer . permissions) -> store
(MAP-STORE  start end . permissions) -> store
(PERMISSIONS store) -> 'read-only 'read+write or 'write-only
(STORE-SET-PERMISSIONS! store permissions) -> unspecified
(ENDIAN store) -> 'big-endian or 'little-endian
(STORE-LENGTH store) -> num-bytes

(STORE-REF-BYTE store address) -> integer
(STORE-REF-WORD store address) -> integer
(STORE-REF-LONG store address) -> integer
(STORE-REF-CHAR store address) -> character
(STORE-SLICE->STRING store start end) -> string

(STORE-SET-BYTE! store address integer) -> unspecified
(STORE-SET-WORD! store address integer) -> unspecified
(STORE-SET-LONG! store address integer) -> unspecified
(STORE-SET-CHAR! store address character)     -> unspecified
(STRING->STORE-SLICE-SET! string store start) -> unspecified
(STORE-SLICE->STORE-SLICE-SET! store1 start1 end1 store2 start2)
 -> unspecified

(FILE->STORE path) -> store
(STORE->FILE store path) -> unspecified
(WRITE-STORE-SLICE store start end . port) -> unspecified

optional:
  (STORE-REF-IEEE-SINGLE->REAL   store address) -> real
  (STORE-REF-IEEE-DOUBLE->REAL   store address) -> real
  (STORE-REF-IEEE-EXTENDED->REAL store address) -> real
  (STORE-SET-IEEE-SINGLE!   store address real) -> unspecified
  (STORE-SET-IEEE-DOUBLE!   store address real) -> unspecified
  (STORE-SET-IEEE-EXTENDED! store address real) -> unspecified
  ...


DISCUSSION:

The Store abstraction allows one to deal with low-level file,
unscanned-vector, and computer memory `objects', allowing device
drivers and other system programs to be written in Scheme.  An
implementation may supply predefined stores which map to computer
memory or memory mapped devices.  Memory which remains fixed, e.g. C
structs and Pascal records can be mapped as stores and dereferenced.
Memory can be copied to memory, file to file, file to memory, etc.

Permissions are used to allow EPROM memory and read-only files to
signal an error upon assignment.  An error is also signaled if an
integer of greater size than the unit is assigned [byte = 8 bits; word
= 2 bytes; long = 4 bytes].

A Scheme character is of implementation-dependent size (e.g. Japanese
or Chinese characters may be multi-byte quantities).

Returned integers are always non-negative.



ISSUES:

No file extension is provided for.

No support for specifying and mapping between multiple address spaces. 


DETAILS:

[Elided -- Hopefully obvious]



;;			--- E O F ---