From: Ryan M. Rifkin
Subject: Q: How to write binary data to a file?
Date: 
Message-ID: <wj0ptvu6fpk.fsf@five-percent-nation.mit.edu>
Hi.

I'm a (relative) Lisp newbie, trying to learn.  I'm interested in
writing integers to a file as 16-bit signed integers.  (The integers I
need to write will fit in this representation.  I am writing audio
data to the file, which is why I need to output in a binary format).

I'm aware of the function write-byte, but I'm not sure how to write my
signed integers.  I could try to implement it on top of write-byte,
but this seems messy.  Is there any reasonable way to do this?
Alternately, I could just output a list of integers, and then write a
six-line perl script to convert, but this seems inelegant.

For the record, I'm using CMUCL.

Cheers,

rif

From: Marco Antoniotti
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <y6cofbe7qr9.fsf@octagon.mrl.nyu.edu>
With CMUCL this should work.

I won't swear on portability and conformance though.

===========================================================================

* (defvar *v* (make-array 5 :element-type '(unsigned-byte 16)
			:initial-contents '( 1 2 3 4 5 )))
*V*
* (with-open-file (z "home:tmp/zut.bin"
		   :element-type '(unsigned-byte 16)
		   :direction :output
		   :if-does-not-exist :create
		   :if-exists :supersede)
		(write-sequence *v* z))
#(1 2 3 4 5)
* (defvar *vv* (make-array 5 :element-type '(unsigned-byte 16)))
*VV*
* *vv*
#(0 0 0 0 0)
* (with-open-file (z "home:tmp/zut.bin"
		   :element-type '(unsigned-byte 16)
		   :direction :input
		   :if-does-not-exist :error)
		(read-sequence *vv* z))
5
* *vv*
#(1 2 3 4 5)

===========================================================================

You will have to look at "home:tmp/zut.bin" in hexl-mode.

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
715 Broadway 10th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: Erik Naggum
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <3240073902064268@naggum.no>
* Ryan M. Rifkin
| I'm a (relative) Lisp newbie, trying to learn.  I'm interested in writing
| integers to a file as 16-bit signed integers.  (The integers I need to write
| will fit in this representation.  I am writing audio data to the file, which
| is why I need to output in a binary format).

  Just specify `:element-type ' (signed-byte 16)� and go ahead and `write-byte�
  values in the appropriate range to the stream.

| I'm aware of the function write-byte, but I'm not sure how to write my
| signed integers.

  `write-byte� does not write IBMese 8-bit bytes, but real bytes, contiguous
  sequences of bits in an integer.  In the words of the Common Lisp Glossary:

byte n.
1. adjacent bits within an integer.  (The specific number of bits can vary
from point to point in the program; see the function `byte�.)
2. an integer in a specified range.  (The specific range can vary from point
to point in the program; see the functions `open� and `write-byte�.)

  This definition of "byte" predates the IBM abuse of the term and comes from
  the PDP-6 and -10 hardware designs, which were 36-bit word machines, meaning
  the smallest addressable unit was one machine word of 36 bits.  I believe IBM
  invented the byte-addressable hardware.

  Your main confusion comes from thinking that "byte" means the same thing in
  Common Lisp as it means in, say, C.

-- 
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.
From: Frode Vatvedt Fjeld
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <2h1y8asss0.fsf@vserver.cs.uit.no>
···@mit.edu (Ryan M. Rifkin) writes:

> [..] I'm aware of the function write-byte, but I'm not sure how to
> write my signed integers.  I could try to implement it on top of
> write-byte, but this seems messy.  Is there any reasonable way to do
> this?

It's not that messy. Just make sure you have a stream with element-type
of 8-bit bytes, which is typically achieved with opening the file with
:element-type '(unsigned-byte 8), and then do something like

  (defun write-16-bits-big-endian (value stream)
    (check-type value (signed-byte 16))
    (write-byte (ldb (byte 8 8) value))
    (write-byte (ldb (byte 8 0) value))
    value)

If you care about performance, CMUCL might or might not support
writing buffers of such bytes directly. Stuff your values into vectors
with that element-type:

  (make-array <buffer-size> :element-type '(signed-byte 16) ..)

Have your stream use the same element-type, and use write-sequence,
something like this:

  (with-open-file (stream <path> :element-type '(signed-byte 16) ..)
    (write-sequence <buffer> stream))

The latter strategy might yield similar performance to the C
equivalent, but depends to a larger extent on the implementation, in
your case CMUCL (which now also determines representational
characteristics like endianess), while the former strategy only
requires the implementation to provide 8-bit binary streams.

From a cursory look at CMUCL (I don't use it much), it seems to
support the write-sequence strategy, because:

  * (upgraded-array-element-type '(signed-byte 16))
  => (SIGNED-BYTE 16)

  * (with-open-file (stream #p"/dev/null" :element-type '(signed-byte 16))
      (stream-element-type stream))
  => (SIGNED-BYTE 16)

This is no guarantee that what you expect actually ends up in the
file, but I believe it's a good indication that CMUCL will do the
"right" thing.


You might also find my binary-types package interesting:
<URL:http://www.cs.uit.no/~frodef/sw/binary-types/>

> Alternately, I could just output a list of integers, and then write
> a six-line perl script to convert, but this seems inelegant.

Please don't... :)

-- 
Frode Vatvedt Fjeld
From: Pascal Costanza
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <al3f7e$kij$1@newsreader2.netcologne.de>
Ryan M. Rifkin wrote:
> Hi.
> 
> I'm a (relative) Lisp newbie, trying to learn.  I'm interested in
> writing integers to a file as 16-bit signed integers.  (The integers I
> need to write will fit in this representation.  I am writing audio
> data to the file, which is why I need to output in a binary format).
> 
> I'm aware of the function write-byte, but I'm not sure how to write my
> signed integers.

In most languages, bytes are defined to be of a fixed size. So usually, 
a byte occupies 8 bits. However, Common Lisp allows you to define your 
bytes to be of arbitrary size, including 16 bits.

You can define the base type of a file when opening the file. So for example

(with-open-file (stream pathname :element-type '(signed-byte 16)
   ...)

lets you operate on a file that containes signed 16-bit values. Here, 
read-byte and write-byte do what you actually want without any further 
ado. (Cool, eh? ;) )

(This example is not complete, you also need to specify that you want to 
write to the particular file, and not just read it. See the 
specifications for open-file and with-open-file. Also, handling of 
pathnames is different from other languages and you need to consult the 
documentation of your Common Lisp implementation for creating correct 
pathnames.)


Pascal
From: Duane Rettig
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <4n0qy61d0.fsf@beta.franz.com>
Pascal Costanza <········@web.de> writes:

> Ryan M. Rifkin wrote:
> > Hi.
> > I'm a (relative) Lisp newbie, trying to learn.  I'm interested in
> 
> > writing integers to a file as 16-bit signed integers.  (The integers I
> > need to write will fit in this representation.  I am writing audio
> > data to the file, which is why I need to output in a binary format).
> > I'm aware of the function write-byte, but I'm not sure how to write
> > my
> 
> > signed integers.
> 
> In most languages, bytes are defined to be of a fixed size. So
> usually, a byte occupies 8 bits. However, Common Lisp allows you to
> define your bytes to be of arbitrary size, including 16 bits.

I don't know too many languages that actually define the term "byte".
However, I'll not argue with the accuracy in modern times of your
statement, especially in light of the almost overwhelming popular usage
of the term "byte" to in fact mean 8 bits.  However, it is historically
inaccurate, and without understanding the history one loses the reasoning
behind the choice of CL in choosing such a definition for byte.  I
always try to use "octet" instead, when referring specifically to
8-bit bytes.

See

http://groups.google.com/groups?q=g:thl1140106249d&dq=&hl=en&lr=&ie=UTF-8&selm=47lgxnrhf.fsf%40beta.franz.com

Unfortunately, the link contained within that article no longer
works, but try instead

http://www.wkonline.com/d/byte.html for similar explanations, or

http://www.bobbemer.com/BYTE.HTM (also, the same article is at
http://serendipity.nofadz.com/hermetic/cfunlib/bemer1.htm
or http://hermetic.magnet.ch/cfunlib/bemer1.htm)

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Pascal Costanza
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <al3p8j$lq3$1@newsreader2.netcologne.de>
Duane Rettig wrote:
> Pascal Costanza <········@web.de> writes:

>>In most languages, bytes are defined to be of a fixed size. So
>>usually, a byte occupies 8 bits. However, Common Lisp allows you to
>>define your bytes to be of arbitrary size, including 16 bits.
> 
> 
> I don't know too many languages that actually define the term "byte".
> However, I'll not argue with the accuracy in modern times of your
> statement, especially in light of the almost overwhelming popular usage
> of the term "byte" to in fact mean 8 bits.  However, it is historically
> inaccurate, 

[...]

Wow, I wasn't aware of that. Thanks for the links - very interesting!

Pascal
From: Espen Vestre
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <kwfzwqp6gr.fsf@merced.netfonds.no>
Duane Rettig <·····@franz.com> writes:

> I don't know too many languages that actually define the term "byte".
> However, I'll not argue with the accuracy in modern times of your
> statement, especially in light of the almost overwhelming popular usage
> of the term "byte" to in fact mean 8 bits.  

I'm starting to think that the the most valuable CS education I ever got was my
exposure to the university DEC-10 computer. Which used several byte sizes (for
instance, a 5-bit character set), which had shared memory, a myriad of extraordinary
computer language implementations (e.g. the famous Edinburgh Prolog), and so on :-)
-- 
  (espen)
From: Rob Warnock
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <unlulo2ktjjnba@corp.supernews.com>
Espen Vestre  <·····@*do-not-spam-me*.vestre.net> wrote:
+---------------
| Duane Rettig <·····@franz.com> writes:
| > I don't know too many languages that actually define the term "byte"...
| 
| I'm starting to think that the the most valuable CS education I ever got
| was my exposure to the university DEC-10 computer. Which used several
| byte sizes...
+---------------

Yeah, me too. I've told the story several (too many?) times:

    <URL:http://groups.google.com/groups?q=rpw3+focal+sortj+macros&hl=en&
         lr=&ie=UTF-8&selm=938v11%24m89cq%241%40fido.engr.sgi.com&rnum=2>
    <URL:http://groups.google.com/groups?q=rpw3+focal+sortj+macros&hl=en&
	 lr=&ie=UTF-8&selm=7meuue%2498dks%40fido.engr.sgi.com&rnum=1>
    <URL:http://groups.google.com/groups?q=rpw3+bit+strips&hl=en&lr=&
	 ie=UTF-8&selm=3232%40fortune.UUCP&rnum=1>

so I won't repeat it here, but the byte pointer hardware on the PDP-10
got used for a *lot* more stuff than just accessing character strings...


-Rob

-----
Rob Warnock, PP-ASEL-IA		<····@rpw3.org>
627 26th Avenue			<URL:http://www.rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Marco Antoniotti
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <y6cadmx7ts2.fsf@octagon.mrl.nyu.edu>
Duane Rettig <·····@franz.com> writes:

> However, I'll not argue with the accuracy in modern times of your
> statement, especially in light of the almost overwhelming popular usage
> of the term "byte" to in fact mean 8 bits.  However, it is historically
> inaccurate, and without understanding the history one loses the reasoning
> behind the choice of CL in choosing such a definition for byte.  I
> always try to use "octet" instead, when referring specifically to
> 8-bit bytes.

Givin' in to the rude French, aren't we? :)

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
715 Broadway 10th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: Duane Rettig
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <4ofbdwzo4.fsf@beta.franz.com>
Marco Antoniotti <·······@cs.nyu.edu> writes:

> Duane Rettig <·····@franz.com> writes:
> 
> > However, I'll not argue with the accuracy in modern times of your
> > statement, especially in light of the almost overwhelming popular usage
> > of the term "byte" to in fact mean 8 bits.  However, it is historically
> > inaccurate, and without understanding the history one loses the reasoning
> > behind the choice of CL in choosing such a definition for byte.  I
> > always try to use "octet" instead, when referring specifically to
> > 8-bit bytes.
> 
> Givin' in to the rude French, aren't we? :)

Sorry?  I don't understand the joke, here.

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Zachary Beane
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <slrnancjtk.ai8.xach@localhost.localdomain>
In article <·············@beta.franz.com>, Duane Rettig wrote:
> Marco Antoniotti <·······@cs.nyu.edu> writes:
> 
>> Duane Rettig <·····@franz.com> writes:
>> 
>> > However, I'll not argue with the accuracy in modern times of your
>> > statement, especially in light of the almost overwhelming popular usage
>> > of the term "byte" to in fact mean 8 bits.  However, it is historically
>> > inaccurate, and without understanding the history one loses the reasoning
>> > behind the choice of CL in choosing such a definition for byte.  I
>> > always try to use "octet" instead, when referring specifically to
>> > 8-bit bytes.
>> 
>> Givin' in to the rude French, aren't we? :)
> 
> Sorry?  I don't understand the joke, here.

I'm not sure what the joke is, either, but it might have something to
do with the French use of new French words for some common programming
terms. They refer to octets and megaoctets instead of bytes and
megabytes. And instead of software they write "logiciels". A recent
conference discussed "logiciels libres", for example.

Zach
-- 
Zachary Beane     ····@xach.com
From: Marco Antoniotti
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <y6cheh561ml.fsf@octagon.mrl.nyu.edu>
····@xach.com (Zachary Beane) writes:

> In article <·············@beta.franz.com>, Duane Rettig wrote:
> > Marco Antoniotti <·······@cs.nyu.edu> writes:
> > 
> >> Duane Rettig <·····@franz.com> writes:
> >> 
        ...
> >> > always try to use "octet" instead, when referring specifically to
> >> > 8-bit bytes.
> >> 
> >> Givin' in to the rude French, aren't we? :)
> > 
> > Sorry?  I don't understand the joke, here.
> 
> I'm not sure what the joke is, either, but it might have something to
> do with the French use of new French words for some common programming
> terms. They refer to octets and megaoctets instead of bytes and
> megabytes. And instead of software they write "logiciels". A recent
> conference discussed "logiciels libres", for example.
> 

Pretty much that :) ... and also the tendency in (most of) the US
media to spurn everything French :)

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
715 Broadway 10th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: Duane Rettig
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <4u1l5iiih.fsf@beta.franz.com>
Marco Antoniotti <·······@cs.nyu.edu> writes:

> ····@xach.com (Zachary Beane) writes:
> 
> > In article <·············@beta.franz.com>, Duane Rettig wrote:
> > > Marco Antoniotti <·······@cs.nyu.edu> writes:
> > > 
> > >> Duane Rettig <·····@franz.com> writes:
> > >> 
>         ...
> > >> > always try to use "octet" instead, when referring specifically to
> > >> > 8-bit bytes.
> > >> 
> > >> Givin' in to the rude French, aren't we? :)
> > > 
> > > Sorry?  I don't understand the joke, here.
> > 
> > I'm not sure what the joke is, either, but it might have something to
> > do with the French use of new French words for some common programming
> > terms. They refer to octets and megaoctets instead of bytes and
> > megabytes. And instead of software they write "logiciels". A recent
> > conference discussed "logiciels libres", for example.
> > 
> 
> Pretty much that :) ... and also the tendency in (most of) the US
> media to spurn everything French :)

You mean "octet"?  Marco, I'm suprised at you.  My dictionary derives
octet as an Italian term, "oct" meaning 8 from the Latin, and
the "et ending is a derivation of the musical term "duet".

And spurning Frech?  At least a third of the English language is
derived from French (but just not "octet" :-)  If the US media
truly spurned everything French or derived from French, they would
produce copy that would sound extremely strange to a native speaker.

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Marco Antoniotti
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <y6cznux40gt.fsf@octagon.mrl.nyu.edu>
Duane Rettig <·····@franz.com> writes:

> Marco Antoniotti <·······@cs.nyu.edu> writes:
> 
> > ····@xach.com (Zachary Beane) writes:
> > 
> > > In article <·············@beta.franz.com>, Duane Rettig wrote:
> > > > Marco Antoniotti <·······@cs.nyu.edu> writes:
> > > > 
> > > >> Duane Rettig <·····@franz.com> writes:
> > > >> 
> >         ...
> > > >> > always try to use "octet" instead, when referring specifically to
> > > >> > 8-bit bytes.
> > > >> 
> > > >> Givin' in to the rude French, aren't we? :)
> > > > 
> > > > Sorry?  I don't understand the joke, here.
> > > 
> > > I'm not sure what the joke is, either, but it might have something to
> > > do with the French use of new French words for some common programming
> > > terms. They refer to octets and megaoctets instead of bytes and
> > > megabytes. And instead of software they write "logiciels". A recent
> > > conference discussed "logiciels libres", for example.
> > > 
> > 
> > Pretty much that :) ... and also the tendency in (most of) the US
> > media to spurn everything French :)
> 
> You mean "octet"?  Marco, I'm suprised at you.  My dictionary derives
> octet as an Italian term, "oct" meaning 8 from the Latin, and
> the "et ending is a derivation of the musical term "duet".

Well, almost.  The correct Italian is "ottetto". As for "duet" it is
still not Italian: the correct form is "duetto".  "octet" is a (AFAIK)
correct French.  Of course it is a Latinism.

I'll pass on the rest.  :)

Cheers


-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
715 Broadway 10th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: Duane Rettig
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <43csprrpq.fsf@beta.franz.com>
Marco Antoniotti <·······@cs.nyu.edu> writes:

> Duane Rettig <·····@franz.com> writes:
> 
> > Marco Antoniotti <·······@cs.nyu.edu> writes:
> > 
> > > ····@xach.com (Zachary Beane) writes:
> > > 
> > > > In article <·············@beta.franz.com>, Duane Rettig wrote:
> > > > > Marco Antoniotti <·······@cs.nyu.edu> writes:
> > > > > 
> > > > >> Duane Rettig <·····@franz.com> writes:
> > > > >> 
> > >         ...
> > > > >> > always try to use "octet" instead, when referring specifically to
> > > > >> > 8-bit bytes.
> > > > >> 
> > > > >> Givin' in to the rude French, aren't we? :)
> > > > > 
> > > > > Sorry?  I don't understand the joke, here.
> > > > 
> > > > I'm not sure what the joke is, either, but it might have something to
> > > > do with the French use of new French words for some common programming
> > > > terms. They refer to octets and megaoctets instead of bytes and
> > > > megabytes. And instead of software they write "logiciels". A recent
> > > > conference discussed "logiciels libres", for example.
> > > > 
> > > 
> > > Pretty much that :) ... and also the tendency in (most of) the US
> > > media to spurn everything French :)
> > 
> > You mean "octet"?  Marco, I'm suprised at you.  My dictionary derives
> > octet as an Italian term, "oct" meaning 8 from the Latin, and
> > the "et ending is a derivation of the musical term "duet".
> 
> Well, almost.  The correct Italian is "ottetto". As for "duet" it is
> still not Italian: the correct form is "duetto".  "octet" is a (AFAIK)
> correct French.  Of course it is a Latinism.

Perhaps, but my English dictionary makes no mention of French in either
of the etymolies for octet or duet.  But in fact, it does
specifically mention Italian for the etymology for duet which
agrees with you on everything but the mention of French:

 "[< Italian duetto (diminuitive) < duo; see etym. under duo]"

and under duo:

 "[< Italian duo < Latin duo = two]"

No mention of French.  Hence my original density to the joke.

> I'll pass on the rest.  :)

Same here; how long can we beat a dead joke?

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Marco Antoniotti
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <y6cit1k4k48.fsf@octagon.mrl.nyu.edu>
Duane Rettig <·····@franz.com> writes:

> Marco Antoniotti <·······@cs.nyu.edu> writes:
> 
> > Well, almost.  The correct Italian is "ottetto". As for "duet" it is
> > still not Italian: the correct form is "duetto".  "octet" is a (AFAIK)
> > correct French.  Of course it is a Latinism.
> 
> Perhaps, but my English dictionary makes no mention of French in either
> of the etymolies for octet or duet.  But in fact, it does
> specifically mention Italian for the etymology for duet which
> agrees with you on everything but the mention of French:
> 
>  "[< Italian duetto (diminuitive) < duo; see etym. under duo]"
> 
> and under duo:
> 
>  "[< Italian duo < Latin duo = two]"
> 
> No mention of French.  Hence my original density to the joke.

Well, I do not know how your dictionary was compiled and I am no
etymologist; the information contained in ther may be right after all.
All I can say is that there is a "rule" in Italian for words denoting
N-tuples up to a certain small number: duetto, terzetto, quartetto,
quintetto, sestetto, settetto, ottetto.

I don't remember my Latin, but I am sure that you may find the roots
in there.

> > I'll pass on the rest.  :)
> 
> Same here; how long can we beat a dead joke?

Not too long :)

As an aside, have you noticed how the best comedians just know when to quit?
Renzo Arbore in Italy and Jerry Seinfeld in the US come to mind.

Ok, ok, enough of this.  Back to read the "ilias".

Cheers


-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
715 Broadway 10th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: Thomas F. Burdick
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <xcvelc8mjci.fsf@hurricane.OCF.Berkeley.EDU>
Duane Rettig <·····@franz.com> writes:

> Perhaps, but my English dictionary makes no mention of French in either
> of the etymolies for octet or duet.

Well, if we're getting out the dictionaries ... *heft* ... my Oxford
says that the English "octet" comes from the Italian "ottetto", or
from the Greek "Oktett".  However, the closest it comes to the 8-bit
byte meaning of the word, is "a group of eight."

My Petit Robert, on the other hand, defines the French "octet" as "a
base composed of eight binary digits, used in most machine languages",
and claims it was derived in 1960 from the root "oct-", with no
mention of Italian, or eight-person ensembles.  Pleasantly enough, it
defines "byte" to mean "a collection of some bits constituting a
complete unit of information", and says it is sometimes used
incorrectly to mean "byte".

So I'd guess that the English meaning for octet of "8-bit byte" comes
from the French, but since English had previously derived the word
"octet" from Italian for other uses, you won't find mention of French
in its etymology in most dictionaries.

> how long can we beat a dead joke?

Is this a challenge?

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Kenny Tilton
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <3D776A17.2050702@nyc.rr.com>
Duane Rettig wrote:
> Perhaps, but my English dictionary makes no mention of French in either
> of the etymolies for octet or duet.

Mine neither, but there is a tantalizing specification of "octette" as 
an alternative to octet. The etymology is the Italian otetto.

My LaRousse translates english byte to french octet, but has no mention 
of octette.

Go figger.

kenny
From: Roger Corman
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <3d778e65.555005145@news.sf.sbcglobal.net>
On Wed, 04 Sep 2002 21:00:01 GMT, Duane Rettig <·····@franz.com> wrote:

>And spurning Frech?  At least a third of the English language is
>derived from French (but just not "octet" :-)  If the US media
>truly spurned everything French or derived from French, they would
>produce copy that would sound extremely strange to a native speaker.
>
I think it is even quite a bit higher (in terms of number of words). Most
words of latin origin actually came from French, and latin origin words 
certainly make up the majority of English words.
From: Raffael Cavallaro
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <aeb7ff58.0209082046.5933c2d8@posting.google.com>
·····@corman.net (Roger Corman) wrote in message news:<··················@news.sf.sbcglobal.net>...
> Most
> words of latin origin actually came from French, and latin origin words 
> certainly make up the majority of English words.

Actually, good dictionaries (e.g., the O.E.D) distinguish between
words derived from french, old french, and Latin.

Since a very small percentage of the english speaking population was
literate for most of the history of the language, and as Latin was the
language of learning, most literate people were directly familiar with
Latin for much of the history of english. In addition, those who would
take it upon themselves to coin a new word (or borrow one) and
_publish_ it (after all, we only have records of those neologisms that
were published) were even more likely to be well educated, and hence,
versed in latin.

So, english acquired many words directly from french (because of the
Norman conquest - the Normans (i.e., Norsemen) spoke french by the
time they invaded England), but also took many directly from latin, as
most educated people read and wrote latin until a century or so ago.
From: Raffael Cavallaro
Subject: germanic v. latinate word counts
Date: 
Message-ID: <aeb7ff58.0209082100.35a6253d@posting.google.com>
·····@corman.net (Roger Corman) wrote in message news:<··················@news.sf.sbcglobal.net>...

> Most words of
  1, 2 & 3 germanic

>latin origin actually
  1, 2 & 3 latinate

>came from French, and
 4, 5, 6, & 7 germanic
 
>latin origin
 4 & 5 latinate

> words
  8 germanic

> certainly
  6 latinate

> make up the
  9, 10, & 11 germanic

> majority
  7 latinate

> of English words.
  12, 13, & 14 germanic.

Not in your sentence, which has more words of germanic origin than
latin/french by two to one. ;)
From: Tim Bradshaw
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <ey3y9agdewk.fsf@cley.com>
* Zachary Beane wrote:

> I'm not sure what the joke is, either, but it might have something to
> do with the French use of new French words for some common programming
> terms. They refer to octets and megaoctets instead of bytes and
> megabytes. And instead of software they write "logiciels". A recent
> conference discussed "logiciels libres", for example.

This is really cool.  Not only have they decided to use a weird term,
*they've got it wrong* because - as any Lisp person should know,
especially one who has read this thread - a byte *isn't* an octet, or
not in all uses of the term!  So some time in some French article
(perhaps on Common Lisp), someone is going to correct `byte' to
`octet' and completely destroy the meaning of what was written

--tim
From: Erik Naggum
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <3240206249349704@naggum.no>
* Tim Bradshaw <···@cley.com>
| This is really cool.  Not only have they decided to use a weird term,
| *they've got it wrong* because - as any Lisp person should know,
| especially one who has read this thread - a byte *isn't* an octet, or
| not in all uses of the term!  So some time in some French article
| (perhaps on Common Lisp), someone is going to correct `byte' to
| `octet' and completely destroy the meaning of what was written

  A Dictionary of Computing from Oxford University Press actually has this
  informative entry:

octet   Eight contiguous bits; an eight bit byte. The term is used instead of
byte to prevent confusion in cases where the term has preexisting hardware
associations, as in machines with 7-bit bytes, 9-bit bytes, 12-bit bytes.

  But their "byte" idea is "a fixed number of bits that can be treated as a
  unit by the computer hardware", which is just plain wrong.

-- 
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.
From: Eric Marsden
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <wzibs7cxows.fsf@melbourne.laas.fr>
>>>>> "dr" == Duane Rettig <·····@franz.com> writes:

  dr> almost overwhelming popular usage of the term "byte" to in fact
  dr> mean 8 bits. However, it is historically inaccurate, and without
  dr> understanding the history one loses the reasoning behind the
  dr> choice of CL in choosing such a definition for byte. I always
  dr> try to use "octet" instead, when referring specifically to 8-bit
  dr> bytes.

yes, I do likewise, but have had referees of scientific articles
"correct" me on this.   

>>>>> "tb" == Tim Bradshaw <···@cley.com> writes:

  tb> Not only have [the French] decided to use a weird term, *they've
  tb> got it wrong* because - as any Lisp person should know,
  tb> especially one who has read this thread - a byte *isn't* an
  tb> octet, or not in all uses of the term!

most dictionaries have a good definition, and use �multiplet� for byte
(and eg �triplet� for a 3-bit byte). The government unfortunately got
it wrong in their official translations for technical terms, published
in the Journal Officiel.

   <URL:http://www.culture.fr/culture/dglf/cogeter/10-10-98-3.htm>


>>>>> "rc" == Roger Corman <·····@corman.net> writes:

  rc> This reminds me of the old Steve Martin line:
  rc>   "Those French, they have a different word for everything!"

c'est �tout�, that's all folks!
  
-- 
Eric Marsden                          <URL:http://www.laas.fr/~emarsden/>
From: Duane Rettig
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <4lm6g6wuk.fsf@beta.franz.com>
Eric Marsden <········@laas.fr> writes:

> >>>>> "dr" == Duane Rettig <·····@franz.com> writes:
> 
>   dr> almost overwhelming popular usage of the term "byte" to in fact
>   dr> mean 8 bits. However, it is historically inaccurate, and without
>   dr> understanding the history one loses the reasoning behind the
>   dr> choice of CL in choosing such a definition for byte. I always
>   dr> try to use "octet" instead, when referring specifically to 8-bit
>   dr> bytes.
> 
> yes, I do likewise, but have had referees of scientific articles
> "correct" me on this.   

See below.

> >>>>> "tb" == Tim Bradshaw <···@cley.com> writes:
> 
>   tb> Not only have [the French] decided to use a weird term, *they've
>   tb> got it wrong* because - as any Lisp person should know,
>   tb> especially one who has read this thread - a byte *isn't* an
>   tb> octet, or not in all uses of the term!
> 
> most dictionaries have a good definition, and use �multiplet� for byte
> (and eg �triplet� for a 3-bit byte). The government unfortunately got
> it wrong in their official translations for technical terms, published
> in the Journal Officiel.
> 
>    <URL:http://www.culture.fr/culture/dglf/cogeter/10-10-98-3.htm>

Wow - This proves that we English speakers couldn't have derived our
definition of octet from the French, because in French, "octet"
means "byte"! :-)


Back to what you said earlier:

> yes, I do likewise, but have had referees of scientific articles
> "correct" me on this.   

But if your articles were in French, and the referees were French, then
they were right to correct you ("When in Rome ..." Oops, I mean ... )

:-)

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Roger Corman
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <3d778d88.554783897@news.sf.sbcglobal.net>
On Wed, 04 Sep 2002 18:23:48 GMT, ····@xach.com (Zachary Beane) wrote:

>In article <·············@beta.franz.com>, Duane Rettig wrote:
>> Marco Antoniotti <·······@cs.nyu.edu> writes:
>> 
>>> Duane Rettig <·····@franz.com> writes:
>>> 
>>> > However, I'll not argue with the accuracy in modern times of your
>>> > statement, especially in light of the almost overwhelming popular usage
>>> > of the term "byte" to in fact mean 8 bits.  However, it is historically
>>> > inaccurate, and without understanding the history one loses the reasoning
>>> > behind the choice of CL in choosing such a definition for byte.  I
>>> > always try to use "octet" instead, when referring specifically to
>>> > 8-bit bytes.
>>> 
>>> Givin' in to the rude French, aren't we? :)
>> 
>> Sorry?  I don't understand the joke, here.
>
>I'm not sure what the joke is, either, but it might have something to
>do with the French use of new French words for some common programming
>terms. They refer to octets and megaoctets instead of bytes and
>megabytes. And instead of software they write "logiciels". A recent
>conference discussed "logiciels libres", for example.
>
This reminds me of the old Steve Martin line:

"Those French, they have a different word for everything!"

(How dare they?)
From: Christopher Browne
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <al5l34$1no7a8$1@ID-125932.news.dfncis.de>
Oops! Marco Antoniotti <·······@cs.nyu.edu> was seen spray-painting on a wall:
> Duane Rettig <·····@franz.com> writes:
>
>> However, I'll not argue with the accuracy in modern times of your
>> statement, especially in light of the almost overwhelming popular usage
>> of the term "byte" to in fact mean 8 bits.  However, it is historically
>> inaccurate, and without understanding the history one loses the reasoning
>> behind the choice of CL in choosing such a definition for byte.  I
>> always try to use "octet" instead, when referring specifically to
>> 8-bit bytes.
>
> Givin' in to the rude French, aren't we? :)

I had to give in to the "rude Italians," last night at dinner, so I
don't think the French have any kind of monopoly on this sort of
thing...
-- 
(reverse (concatenate 'string ··········@" "enworbbc"))
http://cbbrowne.com/info/sap.html
Rules of the  Evil Overlord #106. "If my  supreme command center comes
under attack, I will immediately  flee to safety in my prepared escape
pod and  direct the  defenses from  there. I will  not wait  until the
troops break into my inner sanctum to attempt this."
<http://www.eviloverlord.com/>
From: Marco Antoniotti
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <y6c4rd55f9q.fsf@octagon.mrl.nyu.edu>
Christopher Browne <········@acm.org> writes:

> Oops! Marco Antoniotti <·······@cs.nyu.edu> was seen spray-painting on a wall:
> > Duane Rettig <·····@franz.com> writes:
> >
> >> However, I'll not argue with the accuracy in modern times of your
> >> statement, especially in light of the almost overwhelming popular usage
> >> of the term "byte" to in fact mean 8 bits.  However, it is historically
> >> inaccurate, and without understanding the history one loses the reasoning
> >> behind the choice of CL in choosing such a definition for byte.  I
> >> always try to use "octet" instead, when referring specifically to
> >> 8-bit bytes.
> >
> > Givin' in to the rude French, aren't we? :)
> 
> I had to give in to the "rude Italians," last night at dinner, so I
> don't think the French have any kind of monopoly on this sort of
> thing...

We, rude!?!  How can it be?  We don't take ourselves seriously enough
to be rude. :)

Cheers


-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
715 Broadway 10th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: ilias
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <3D776EAD.7090302@pontos.net>
Ryan M. Rifkin wrote:
> Hi.
> 
> I'm a (relative) Lisp newbie, trying to learn.  I'm interested in
> writing integers to a file as 16-bit signed integers.  (The integers I
> need to write will fit in this representation.  I am writing audio
> data to the file, which is why I need to output in a binary format).
> 
> I'm aware of the function write-byte, but I'm not sure how to write my
> signed integers.  I could try to implement it on top of write-byte,
> but this seems messy.  Is there any reasonable way to do this?
> Alternately, I could just output a list of integers, and then write a
> six-line perl script to convert, but this seems inelegant.
> 
> For the record, I'm using CMUCL.
> 
> Cheers,
> 
> rif

you can of course alias the name 'write-byte' to the precise name 
'write-element'.

(defmacro write-byte (&rest args)
   `( write-element ,@args))

just another version.
From: ilias
Subject: Re: Q: How to write binary data to a file?
Date: 
Message-ID: <3D77AF69.7060208@pontos.net>
> you can of course alias the name 'write-byte' to the precise name 
> 'write-element'.
> 
 > (defmacro write-byte (&rest args)
 >   `( write-element ,@args))
> 
> just another version.
> 

sorry the opposite of course:

(defmacro write-element (&rest args)
   `( write-byte ,@args))

and 'precise' is of course a relative.