Hello Richard,
On Mon, May 19, 2003 at 10:54:18AM +0200, Richard A. O'Keefe wrote:
text version: 3.95 user + 0.13 system = 4.08 total seconds. binary version: 5.06 user + 2.08 system = 7.14 total seconds.
By my definition 'text' streams are understood to be a subset of all 'binary' streams. I cannot comment these numbers more without any clue about how the files were actually encoded.
If you want C, you know where to find it, and you can call it from Prolog.
How then do I efficiently delegate to my C snippet a block of data that my Prolog program should acquire from some external source ?
(3) I have used binary data transmission between programs. (...)
I understand your grief very well. That's why my original statement contained the note "even if [text] is often greatly appreciated in practice". Any stream format is essentially a convention between the producing and the receiving ends, and today's computer architecture and the available tools tend to favour conventions that are immediately human-readable.
Here, of course, I'm referring to NATIVE binary formats. If you talk about things like ASN.1 or XDR, most of the difficulties I mentioned go away. But so, of course, does the claimed efficiency advantage of binary representations.
I am not particularly talking about 'native' binary, if you mean by that processor- or whatever-dependent format. I am not particularly talking about standards like ASN.1, either. There is plenty of room inbetween, where you assign a well-defined but custom meaning to a sequence of bytes (as opposed to a sequence of words or lines).
SWI Prolog programmers routinely use atoms where other Prolog programmers might have used character lists.
I am talking about 'SWI strings': atom-like objects that are not guaranteed to be unique. These (not atoms) have a minimal allocation overhead which is 'amortized constant' with respect to their length (where 'amortized constant' has the precise complexity theory meaning).
Actually reading data into that buffer is a single system call. There is no need for any loop in your program, the OS kernel handles all details.
My mistake, there is indeed a loop needed here. However this loop will only ever execute a few iterations; the user time spent reading a block is, again, amortized constant in the length of the block on reasonable Unix implementations.
abstraction inversion (http://cliki.tunes.org/Abstraction%20Inversion)
The pointer was meant to clarify the precise definition in which I wanted to use the term.
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/ -----------------------------------------------------------------------------