Hello,
On Tue, May 13, 2003 at 10:55:21AM +1200, Richard A. O'Keefe wrote:
Armin Rigo <arigo(a)tunes.org> wrote: However, the stream concept of all Prolog implementations I know seems very old-fashioned to me; doesn't any give the user a way to define his own streams (i.e. objects that would be usable in lieu of streams in the built-in predicates, but whose byte-level read and write operations are user-defined predicates) ? That would nicely solve this and other problems.
Quintus Prolog has *serious* (but *SERIOUS*) support for just that.
Thanks for the notice !
One difference between this and what Armin Rigo suggests is that the code you plugged in for your own stream types had to be written in C. (...)
You want to work in terms of a BLOCK at a time.
Yes, exactly. Even on Unix in C nobody uses the character-oriented functions on the C API any more; using block-oriented functions is much more efficient. The most efficient solution is even probably to use mmap() to map the whole file in the memory space. This is what I meant when I complained about the old-fashioned character of the standard Prolog predicates of the get_byte family.
So it would make sense to me to introduce block-oriented predicates in Prolog. With a correct design, user-defined predicates could then be used to define any new type of "blockstream" with very reasonable overhead. For example, I would find it very natural to have a pair of predicates get_string and put_string with read or write a string of bytes from/to a stream. Making them dynamic and defining all other predicates (like get_byte, for compatibility) in term of them would allow user-defined streams with little overhead.
A bientôt,
Armin. ============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ -----------------------------------------------------------------------------