From: jkc
Subject: How to read a binary floating-point file?
Date: 
Message-ID: <1153934975.587925.114100@p79g2000cwp.googlegroups.com>
I've spent hours parsing comp.lang.lisp and various UFFI, CFFI
documents, the CMUCL manual, trying to figure out how to read a binary
floating point file in Lisp off and on for the last week without
success. I'm hoping someone here will help me.

The files in question are written on the same machine Lisp is running
on, using something analagous to this C fragment:

  FILE fp* = fopen("f.bin", "wb");
  fwrite (fvector, 4, 1000, fp);

I ran across the following Lisp code (posted by rif):

  (asdf:operate 'asdf:load-op :uffi)
  (use-package :uffi)

  (defun save-df-array (array file-handle)
    (declare (type (simple-array double-float (*)) array))
    (%fwrite (sys:vector-sap array)
           8
           (length array)
           file-handle))

  (defun read-df-array (array file-handle)
  (declare (type (simple-array double-float (*)) array))
    (%fread (sys:vector-sap array)
          8
          (length array)
          file-handle))

  (defmacro with-fopen-file ((var path mode) &body body)
    `(let ((,var (fopen ,path ,mode)))
      (unwind-protect
           (if (= (%fp-is-null-p ,var) 1)
               (error "Error with file ~A (mode ~A): ~A~%" ,path ,mode
(%get-errno))
               (multiple-value-prog1
                   (progn ,@body)))
        (%fclose ,var))))

Unfortunately, the 'READ-DF-ARRAY function won't compile; I get the
following warnings:

-+  Warnings (2)
 |-- Undefined function %FREAD
 `-- This function is undefined:
       %FREAD


Presumably, the $FREAD function needs to be defined previously, but all
my attempts to do so fail.
 
Can someone help me out here?

Thanks
-jkc

From: William James
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <1153942580.647260.126280@h48g2000cwc.googlegroups.com>
jkc wrote:
> I've spent hours parsing comp.lang.lisp and various UFFI, CFFI
> documents, the CMUCL manual, trying to figure out how to read a binary
> floating point file in Lisp off and on for the last week without
> success. I'm hoping someone here will help me.
>
> The files in question are written on the same machine Lisp is running
> on, using something analagous to this C fragment:
>
>   FILE fp* = fopen("f.bin", "wb");
>   fwrite (fvector, 4, 1000, fp);
>
> I ran across the following Lisp code (posted by rif):
>
>   (asdf:operate 'asdf:load-op :uffi)
>   (use-package :uffi)
>
>   (defun save-df-array (array file-handle)
>     (declare (type (simple-array double-float (*)) array))
>     (%fwrite (sys:vector-sap array)
>            8
>            (length array)
>            file-handle))
>
>   (defun read-df-array (array file-handle)
>   (declare (type (simple-array double-float (*)) array))
>     (%fread (sys:vector-sap array)
>           8
>           (length array)
>           file-handle))
>
>   (defmacro with-fopen-file ((var path mode) &body body)
>     `(let ((,var (fopen ,path ,mode)))
>       (unwind-protect
>            (if (= (%fp-is-null-p ,var) 1)
>                (error "Error with file ~A (mode ~A): ~A~%" ,path ,mode
> (%get-errno))
>                (multiple-value-prog1
>                    (progn ,@body)))
>         (%fclose ,var))))
>
> Unfortunately, the 'READ-DF-ARRAY function won't compile; I get the
> following warnings:
>
> -+  Warnings (2)
>  |-- Undefined function %FREAD
>  `-- This function is undefined:
>        %FREAD
>
>
> Presumably, the $FREAD function needs to be defined previously, but all
> my attempts to do so fail.
>
> Can someone help me out here?
>
> Thanks
> -jkc

In MatzLisp (a.k.a. Ruby):

# Make array containing 4 floats.
a = (2..5).map{ |x| x**0.5 }

# Make a file 16-bytes long containing the 4 floats.
File.open( "junk3", "w" ) { |handle|
  handle.print a.pack( "f*" ) }

# Read and print the floats.
puts IO.read( "junk3").unpack( "f*" )

----
Output:

1.41421353816986
1.73205077648163
2.0
2.2360680103302
From: Paolo Amoroso
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <8764hknszg.fsf@plato.moon.paoloamoroso.it>
"jkc" <·······@makewavs.com> writes:

> I've spent hours parsing comp.lang.lisp and various UFFI, CFFI
> documents, the CMUCL manual, trying to figure out how to read a binary
> floating point file in Lisp off and on for the last week without
> success. I'm hoping someone here will help me.

See:

  read-bytes-standalone
  http://www.cl-user.net/asp/libs/read-bytes-standalone


Paolo
-- 
Why Lisp? http://wiki.alu.org/RtL%20Highlight%20Film
The Common Lisp Directory: http://www.cl-user.net
From: jkc
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <pan.2006.07.27.01.35.55.711664@makewavs.com>
On Wed, 26 Jul 2006 20:03:47 +0200, Paolo Amoroso wrote:

> See:
> 
>   read-bytes-standalone
>   http://www.cl-user.net/asp/libs/read-bytes-standalone
> 
> 
> Paolo

Thank you, Paolo. I did run into that, but it appeared to be designed to
read a file one float at a time. Wouldn't this be incredibly slow for
large files? (say, 10^6 floats). Isn't there a way to allocate a simple
vector, pass a pointer to it and fill it quickly by calling fread?

I've seen code fragments involving UFFI or CFFI to do it, but always
missing essential details (at least to me).

Regards,

jkc
From: Thomas F. Burdick
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <xcvd5bi5gp1.fsf@conquest.OCF.Berkeley.EDU>
jkc <·······@makewavs.com> writes:

> On Wed, 26 Jul 2006 20:03:47 +0200, Paolo Amoroso wrote:
> 
> > See:
> > 
> >   read-bytes-standalone
> >   http://www.cl-user.net/asp/libs/read-bytes-standalone
> > 
> > 
> > Paolo
> 
> Thank you, Paolo. I did run into that, but it appeared to be designed to
> read a file one float at a time. Wouldn't this be incredibly slow for
> large files? (say, 10^6 floats). Isn't there a way to allocate a simple
> vector, pass a pointer to it and fill it quickly by calling fread?
> 
> I've seen code fragments involving UFFI or CFFI to do it, but always
> missing essential details (at least to me).

The most efficient way to do this would be to mmap the file, and use
that as an alien array.  Something like (cast mmapped (* double-float))
From: James Bielman
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <87wt9zpveg.fsf@jamesjb.com>
"jkc" <·······@makewavs.com> writes:

> I've spent hours parsing comp.lang.lisp and various UFFI, CFFI
> documents, the CMUCL manual, trying to figure out how to read a binary
> floating point file in Lisp off and on for the last week without
> success. I'm hoping someone here will help me.
>
> I ran across the following Lisp code (posted by rif):

[...]

> Unfortunately, the 'READ-DF-ARRAY function won't compile; I get the
> following warnings:
>
> -+  Warnings (2)
>  |-- Undefined function %FREAD
>  `-- This function is undefined:
>        %FREAD

Indeed, because it has not been defined!  You want to define a Lisp
function %FREAD that calls the foreign function "fread"---for UFFI,
add something like (from memory, my UFFI-fu is rusty):

(def-function ("fread" %fread)
  ((ptr :pointer-void)
   (size :long)
   (nmemb :long)
   (stream :pointer-void))
  :returning :long)

The equivalent incantation in CFFI is:

(defcfun ("fread" %fread) :long
  (ptr :pointer)
  (size :long)
  (nmemb :long)
  (stream :pointer))

Note that neither UFFI nor CFFI export an operator that is the exact
equivalent of VECTOR-SAP, so there is still a portability issue there.
There is a similar feature in CFFI, but it requires using a special
constructor for the array, which is necessary for some CL
implementations.

You may also need to look into disabling garbage collection or
instructing the GC not to move your array for the duration of the
system call, for maximum safety.  I don't know about CMUCL, but in
SBCL I would suggest the use of WITH-PINNED-OBJECTS.

James
From: Rob Warnock
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <9NKdnZZs4Jex3VXZnZ2dnUVZ_qOdnZ2d@speakeasy.net>
James Bielman  <·······@jamesjb.com> wrote:
+---------------
| You may also need to look into disabling garbage collection or
| instructing the GC not to move your array for the duration of the
| system call, for maximum safety.  I don't know about CMUCL, but in
| SBCL I would suggest the use of WITH-PINNED-OBJECTS.
+---------------

    cmu> (describe 'system:without-gcing)

    WITHOUT-GCING is an external symbol in the SYSTEM package.
    Macro-function: #<Function (:MACRO SYSTEM:WITHOUT-GCING) {102BE7A9}>
    Macro arguments:
      (&rest body)
    Macro documentation:
      Executes the forms in the body without doing a garbage collection.
    ...
    cmu> 

This should surround the call to (%FREAD (SYS:VECTOR-SAP array) ...).

Though note that in compiled code, VECTOR-SAP doesn't cons.
So since CMUCL is single-threaded (from the OS/s POV), in practice
it's safe even without the SYSTEM:WITHOUT-GCING, provided all the
other arguments to %FREAD have been precomputed as well. [This is
probably *not* the case in SBCL on platforms on which it supports
native threading.]


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: jkc
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <1154019647.324943.308060@h48g2000cwc.googlegroups.com>
Thank you, all. I succeeded using UFFI. My simple code follows. If you
see any problems with it, don't hesitate to criticize.

I'm still working on the CFFI version.

-jkc

(asdf:operate 'asdf:load-op :uffi)
(use-package :uffi)

(def-function ("fopen" %fopen)
  ((path :cstring)
   (mode :cstring))
  :returning :pointer-void)

(def-function ("fclose" %fclose)
  ((ptr :pointer-void))
  :returning :void)

(def-function ("fread" %fread)
  ((ptr :pointer-void)
   (size :long)
   (nmemb :long)
   (stream :pointer-void))
  :returning :long)

(def-function ("fwrite" %fwrite)
  ((ptr :pointer-void)
   (size :long)
   (nmemb :long)
   (stream :pointer-void))
  :returning :long)

(defun write-df-array (array file-handle)
  (declare (type (simple-array double-float (*)) array))
  (system::without-gcing
   (%fwrite (sys:vector-sap array)
	    8
	    (length array)
	    file-handle)))

(defun read-df-array (array file-handle)
  (declare (type (simple-array double-float (*)) array))
  (system::without-gcing
    (%fread (sys:vector-sap array)
	    8
	    (length array)
	    file-handle)))

(defmacro with-fopen-file ((var path mode) &body body)
    `(let ((,var (%fopen ,path ,mode)))
      (unwind-protect
           (if (null-pointer-p ,var)
               (error "Error opening file ~A (mode ~A)~%" ,path ,mode)
               (multiple-value-prog1 (progn ,@body)))
        (%fclose ,var))))

;; TESTS
(with-fopen-file (os "d10.bin" "rb")
  (let ((ar (make-array 10 :element-type 'double-float)))
    (read-df-array ar os)
    (print ar)))

(with-fopen-file (os "d10.bin" "wb")
  (let ((ar (make-array 10 :element-type 'double-float)))
    (dotimes (i 10) (setf (aref ar i) (coerce i 'double-float)))
    (write-df-array ar os)))
From: Duane Rettig
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <o08xmeb7t2.fsf@franz.com>
"jkc" <·······@makewavs.com> writes:

> Thank you, all. I succeeded using UFFI. My simple code follows. If you
> see any problems with it, don't hesitate to criticize.
>
> I'm still working on the CFFI version.
>
> -jkc


 [ ... ]

Hmm, seems complex to me.  Simple-streams has read-vector 
http://www.franz.com/support/documentation/8.0/doc/operators/excl/read-vector.htm
and write-vector
http://www.franz.com/support/documentation/8.0/doc/operators/excl/write-vector.htm
that do what you want without needing any ffi.

-- 
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: jkc
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <1154097275.825035.193990@s13g2000cwa.googlegroups.com>
Duane Rettig wrote:

>  [ ... ]
>
> Hmm, seems complex to me.  Simple-streams has read-vector
> http://www.franz.com/support/documentation/8.0/doc/operators/excl/read-vector.htm
> and write-vector
> http://www.franz.com/support/documentation/8.0/doc/operators/excl/write-vector.htm
> that do what you want without needing any ffi.

I looked at that, Duane, but wasn't able to make it work. Here's what I
tried:

(let ((vec (make-array 10 :element-type 'double-float)))
  (with-open-file (os "d10.bin")
    (read-vector vec os)
    (print vec)))

where "d10.bin" is a 10 double-float binary file. It produces the
following error:

Type-error in KERNEL::OBJECT-NOT-DOUBLE-FLOAT-ERROR-HANDLER:
   #\Null is not of type DOUBLE-FLOAT

I can read it using this CFFI function:

(with-fopen-file (os "d10.bin" "rb")
  (let ((ar (make-array 10 :element-type 'double-float)))
    (read-df-array ar os)
    (print ar)))

#(0.0d0 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0 6.0d0 7.0d0 8.0d0 9.0d0)
  
--jeff
From: Duane Rettig
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <o0fygl311r.fsf@franz.com>
"jkc" <·······@makewavs.com> writes:

> Duane Rettig wrote:
>
>>  [ ... ]
>>
>> Hmm, seems complex to me.  Simple-streams has read-vector
>> http://www.franz.com/support/documentation/8.0/doc/operators/excl/read-vector.htm
>> and write-vector
>> http://www.franz.com/support/documentation/8.0/doc/operators/excl/write-vector.htm
>> that do what you want without needing any ffi.
>
> I looked at that, Duane, but wasn't able to make it work. Here's what I
> tried:
>
> (let ((vec (make-array 10 :element-type 'double-float)))
>   (with-open-file (os "d10.bin")
>     (read-vector vec os)
>     (print vec)))
>
> where "d10.bin" is a 10 double-float binary file. It produces the
> following error:
>
> Type-error in KERNEL::OBJECT-NOT-DOUBLE-FLOAT-ERROR-HANDLER:
>    #\Null is not of type DOUBLE-FLOAT

You must be using a simple-streams implementation from another lisp.
Allegro CL doesn't have a KERNEL package.

What you're seeing above is a bug; you should report it to that
lisp's support team.

It works fine in Allegro CL (for which you can download the Express
Edition for free):

CL-USER(1): (defvar *x*
               (make-array 10 :element-type 'double-float
                              :initial-contents
                              (loop for i from 0.0d0 to 9.0d0
                                    collect i)))
*X*
CL-USER(2): *x*
#(0.0d0 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0 6.0d0 7.0d0 8.0d0 9.0d0)
CL-USER(3): (with-open-file (s "z.dat" :direction :io
                                       :if-exists :overwrite
                                       :if-does-not-exist :create)
(write-vector *x* s))
80
CL-USER(4): (defvar *y* (make-array 10 :element-type 'double-float
                                       :initial-element 10.0d0))
*Y*
CL-USER(5): (with-open-file (s "z.dat")
(read-vector *y* s))
80
CL-USER(6): *y*
#(0.0d0 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0 6.0d0 7.0d0 8.0d0 9.0d0)
CL-USER(7): 

-- 
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: jkc
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <pan.2006.07.28.21.47.07.642286@makewavs.com>
On Fri, 28 Jul 2006 13:52:00 -0700, Duane Rettig wrote:
>>
>> Type-error in KERNEL::OBJECT-NOT-DOUBLE-FLOAT-ERROR-HANDLER:
>>    #\Null is not of type DOUBLE-FLOAT
> 
> You must be using a simple-streams implementation from another lisp.
> Allegro CL doesn't have a KERNEL package.
> 
> What you're seeing above is a bug; you should report it to that
> lisp's support team.

I'm using CMUCL (I thought I mentioned that). If this is indeed a bug, I
will see what I can do to let them know about it. 

Thank you. 
-jeff
From: Duane Rettig
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <o0irlgsakf.fsf@franz.com>
jkc <·······@makewavs.com> writes:

> On Fri, 28 Jul 2006 13:52:00 -0700, Duane Rettig wrote:
>>>
>>> Type-error in KERNEL::OBJECT-NOT-DOUBLE-FLOAT-ERROR-HANDLER:
>>>    #\Null is not of type DOUBLE-FLOAT
>> 
>> You must be using a simple-streams implementation from another lisp.
>> Allegro CL doesn't have a KERNEL package.
>> 
>> What you're seeing above is a bug; you should report it to that
>> lisp's support team.
>
> I'm using CMUCL (I thought I mentioned that). If this is indeed a bug, I
> will see what I can do to let them know about it. 

Or fix it yourself.  It is, after all, free software - it should be
easy :-)

> Thank you. 
> -jeff

You're welcome.

-- 
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 Bourguignon
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <87lkqbzsz4.fsf@thalassa.informatimago.com>
Duane Rettig <·····@franz.com> writes:

> jkc <·······@makewavs.com> writes:
>
>> On Fri, 28 Jul 2006 13:52:00 -0700, Duane Rettig wrote:
>>>>
>>>> Type-error in KERNEL::OBJECT-NOT-DOUBLE-FLOAT-ERROR-HANDLER:
>>>>    #\Null is not of type DOUBLE-FLOAT
>>> 
>>> You must be using a simple-streams implementation from another lisp.
>>> Allegro CL doesn't have a KERNEL package.
>>> 
>>> What you're seeing above is a bug; you should report it to that
>>> lisp's support team.
>>
>> I'm using CMUCL (I thought I mentioned that). If this is indeed a bug, I
>> will see what I can do to let them know about it. 
>
> Or fix it yourself.  It is, after all, free software - it should be
> easy :-)

s/easy/possible/

We never claimed it would be easy, but that it'd be possible.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

CONSUMER NOTICE: Because of the "uncertainty principle," it is
impossible for the consumer to simultaneously know both the precise
location and velocity of this product.
From: Duane Rettig
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <o0ejw3snbb.fsf@franz.com>
Pascal Bourguignon <···@informatimago.com> writes:

> Duane Rettig <·····@franz.com> writes:
>
>> jkc <·······@makewavs.com> writes:
>>
>>> On Fri, 28 Jul 2006 13:52:00 -0700, Duane Rettig wrote:
>>>>>
>>>>> Type-error in KERNEL::OBJECT-NOT-DOUBLE-FLOAT-ERROR-HANDLER:
>>>>>    #\Null is not of type DOUBLE-FLOAT
>>>> 
>>>> You must be using a simple-streams implementation from another lisp.
>>>> Allegro CL doesn't have a KERNEL package.
>>>> 
>>>> What you're seeing above is a bug; you should report it to that
>>>> lisp's support team.
>>>
>>> I'm using CMUCL (I thought I mentioned that). If this is indeed a bug, I
>>> will see what I can do to let them know about it. 
>>
>> Or fix it yourself.  It is, after all, free software - it should be
>> easy :-)
>
> s/easy/possible/

More accurately:

s/easy :-)/possible./


> We never claimed it would be easy, but that it'd be possible.

A little testy, are we, in the face of a joke?  It was my little jab
at the obviously long-winded and sometimes irate posturing being done
elsewhere on this NG.  But wait a minute, isn't it someone like me
that should have the right to be irritated - I who put my livlihood
on the line with no other source of income, in spite of strong
competition from many free software vendors?  Nah, let's just let it
go...

-- 
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 Bourguignon
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <878xmbznq5.fsf@thalassa.informatimago.com>
Duane Rettig <·····@franz.com> writes:
>> We never claimed it would be easy, but that it'd be possible.
>
> A little testy, are we, in the face of a joke?  It was my little jab
> at the obviously long-winded and sometimes irate posturing being done
> elsewhere on this NG.  But wait a minute, isn't it someone like me
> that should have the right to be irritated - I who put my livlihood
> on the line with no other source of income, in spite of strong
> competition from many free software vendors?  Nah, let's just let it
> go...

Note that you and Franz may not be at fault at all, but during the
past 30 years a lot of users and programmers have been burned by the
behavior of proprietary software vendors, whether the company failed
and the software sources and support disappeared, or the company became
too big and failed to attend the needs of smaller niche users, or just
unresponsiveness, etc.  Free software resolves these problems by puting
the users in charge of their software, as it was in the first epoch.

Proportionnaly, there was certainly more jobs for IT people when each
corporation that used computers had their own programmer team, than
nowadays when programmers concentrate at software vendors.  Free
software is an opportunity to add some programmer jobs back to the
users.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"By filing this bug report you have challenged the honor of my
family. Prepare to die!"
From: Duane Rettig
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <o0ac6rslx3.fsf@franz.com>
Pascal Bourguignon <···@informatimago.com> writes:

> Duane Rettig <·····@franz.com> writes:
>>> We never claimed it would be easy, but that it'd be possible.
>>
>> A little testy, are we, in the face of a joke?  It was my little jab
>> at the obviously long-winded and sometimes irate posturing being done
>> elsewhere on this NG.  But wait a minute, isn't it someone like me
>> that should have the right to be irritated - I who put my livlihood
>> on the line with no other source of income, in spite of strong
>> competition from many free software vendors?  Nah, let's just let it
>> go...
>
> Note that you and Franz may not be at fault at all, but during the
> past 30 years a lot of users and programmers have been burned by the
> behavior of proprietary software vendors, whether the company failed
> and the software sources and support disappeared, or the company became
> too big and failed to attend the needs of smaller niche users, or just
> unresponsiveness, etc.  Free software resolves these problems by puting
> the users in charge of their software, as it was in the first epoch.
>
> Proportionnaly, there was certainly more jobs for IT people when each
> corporation that used computers had their own programmer team, than
> nowadays when programmers concentrate at software vendors.  Free
> software is an opportunity to add some programmer jobs back to the
> users.

I will not enter into this argument.

-- 
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 Bourguignon
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <874pwzzlou.fsf@thalassa.informatimago.com>
Duane Rettig <·····@franz.com> writes:
>> Proportionnaly, there was certainly more jobs for IT people when each
>> corporation that used computers had their own programmer team, than
>> nowadays when programmers concentrate at software vendors.  Free
>> software is an opportunity to add some programmer jobs back to the
>> users.
>
> I will not enter into this argument.

You have already.  
You're saying that free software takes work from programmers. 
I believe that free software gives more work to programmers.
Unfortunately we only have anecdotal data about it.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
In deep sleep hear sound,
Cat vomit hairball somewhere.
Will find in morning.
From: Duane Rettig
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <o064hfsjko.fsf@franz.com>
Pascal Bourguignon <···@informatimago.com> writes:

> Duane Rettig <·····@franz.com> writes:
>>> Proportionnaly, there was certainly more jobs for IT people when each
>>> corporation that used computers had their own programmer team, than
>>> nowadays when programmers concentrate at software vendors.  Free
>>> software is an opportunity to add some programmer jobs back to the
>>> users.
>>
>> I will not enter into this argument.
>
> You have already.  

Sorry, but no.

> You're saying that free software takes work from programmers. 

This is precisely what all of these arguments are about (it's not about
free software, but about who says somebody says something that they
have not said).  I will not take part.

> I believe that free software gives more work to programmers.

Believe what you wish.  You do not know what I believe, because you
have not asked me and I have not said.

> Unfortunately we only have anecdotal data about it.

OK, whatever.

-- 
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 Bourguignon
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <87y7uby5i9.fsf@thalassa.informatimago.com>
Duane Rettig <·····@franz.com> writes:

> Pascal Bourguignon <···@informatimago.com> writes:
>
>> Duane Rettig <·····@franz.com> writes:
>>>> Proportionnaly, there was certainly more jobs for IT people when each
>>>> corporation that used computers had their own programmer team, than
>>>> nowadays when programmers concentrate at software vendors.  Free
>>>> software is an opportunity to add some programmer jobs back to the
>>>> users.
>>>
>>> I will not enter into this argument.
>>
>> You have already.  
>
> Sorry, but no.

It's me who is sorry, I made a confusion of person.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

This universe shipped by weight, not volume.  Some expansion may have
occurred during shipment.
From: Duane Rettig
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <o01ws3siuj.fsf@franz.com>
Pascal Bourguignon <···@informatimago.com> writes:

> Duane Rettig <·····@franz.com> writes:
>
>> Pascal Bourguignon <···@informatimago.com> writes:
>>
>>> Duane Rettig <·····@franz.com> writes:
>>>>> Proportionnaly, there was certainly more jobs for IT people when each
>>>>> corporation that used computers had their own programmer team, than
>>>>> nowadays when programmers concentrate at software vendors.  Free
>>>>> software is an opportunity to add some programmer jobs back to the
>>>>> users.
>>>>
>>>> I will not enter into this argument.
>>>
>>> You have already.  
>>
>> Sorry, but no.
>
> It's me who is sorry, I made a confusion of person.

No problem.

-- 
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: Ken Tilton
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <bIZyg.4057$yN1.911@fe12.lga>
Pascal Bourguignon wrote:
> Duane Rettig <·····@franz.com> writes:
> 
> 
>>jkc <·······@makewavs.com> writes:
>>
>>
>>>On Fri, 28 Jul 2006 13:52:00 -0700, Duane Rettig wrote:
>>>
>>>>>Type-error in KERNEL::OBJECT-NOT-DOUBLE-FLOAT-ERROR-HANDLER:
>>>>>   #\Null is not of type DOUBLE-FLOAT
>>>>
>>>>You must be using a simple-streams implementation from another lisp.
>>>>Allegro CL doesn't have a KERNEL package.
>>>>
>>>>What you're seeing above is a bug; you should report it to that
>>>>lisp's support team.
>>>
>>>I'm using CMUCL (I thought I mentioned that). If this is indeed a bug, I
>>>will see what I can do to let them know about it. 
>>
>>Or fix it yourself.  It is, after all, free software - it should be
>>easy :-)
> 
> 
> s/easy/possible/
> 
> We never claimed it would be easy, but that it'd be possible.
> 

Because CMUCL is Turing equivalent? <sigh> The poor guy has already 
spent more in time-dollars on this one bug than the cost of a pro 
license to Lispworks:

> I've spent hours parsing comp.lang.lisp and various UFFI, CFFI
> documents, the CMUCL manual, trying to figure out how to read a binary
> floating point file in Lisp off and on for the last week without
> success.

You want to upgrade his waste to an enterprise license for ACL?

kt (LMAO because all this time I thought "how could a 'reading binary' 
thread in any way relate to my only interest here, viz. the outing of 
the FSF as the biggest waste of energy on the planet?". k

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Pascal Bourguignon
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <87psfnxtid.fsf@thalassa.informatimago.com>
Ken Tilton <·········@gmail.com> writes:
> kt (LMAO because all this time I thought "how could a 'reading binary'
> thread in any way relate to my only interest here, viz. the outing of
> the FSF as the biggest waste of energy on the planet?". k

CMUCL is Public Domain, not GPL.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"This machine is a piece of GAGH!  I need dual Opteron 850
processors if I am to do battle with this code!"
From: Pascal Bourguignon
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <87lkqbxtfi.fsf@thalassa.informatimago.com>
Pascal Bourguignon <···@informatimago.com> writes:

> Ken Tilton <·········@gmail.com> writes:
>> kt (LMAO because all this time I thought "how could a 'reading binary'
>> thread in any way relate to my only interest here, viz. the outing of
>> the FSF as the biggest waste of energy on the planet?". k
>
> CMUCL is Public Domain, not GPL.

Well at least some source files of CMUCL are.  I've only watched one.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"This machine is a piece of GAGH!  I need dual Opteron 850
processors if I am to do battle with this code!"
From: Rob Warnock
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <xM-dnZDhrbaDxlDZnZ2dnUVZ_qSdnZ2d@speakeasy.net>
Pascal Bourguignon  <···@informatimago.com> wrote:
+---------------
| Pascal Bourguignon <···@informatimago.com> writes:
| > CMUCL is Public Domain, not GPL.
| 
| Well at least some source files of CMUCL are.  I've only watched one.
+---------------

Almost all of CMUCL is "public domain". Where there are copyrights,
they are mostly of the "MIT" or "BSD" flavors:

  - Large hunks of CLX are "Copyright (C) 1987 Texas Instruments",
    but with an MIT-style permission clause. The "clx/defsystem.lisp"
    also adds "Portions Copyright (C) 1988, 1989 Franz Inc.", but
    retains the MIT-style permissions. Ditto "clx/doc.lisp", with
    the additional copyright holder being MIT.

  - The LOOP macro, "src/code/loop.lisp", is Copyright 1986 by MIT
    and 1989, 1990, 1991, 1992 by Symbolics. [MIT-style]

  - "code/pprint-loop.lisp" says "taken from Dick Water's XP", and
    copies MIT-style permissions said to have come from there, but
    there is no explicit copyright or date given.

  - "contrib/demos/demos.lisp" has a *bunch* of authors & dates
    credited, but only one actual "Copyright" [an MIT-style one].

  - Most of the PCL-based CLOS stuff is "Copyright (c) 1985, 1986, 1987,
    1988, 1989, 1990 Xerox Corporation" with MIT-style permissions,
    except for an added "must comply with all applicable United States
    export control laws" clause. [Well, duh!]

  - A massive amount of recent tuning on CLOS (and "fwrappers")
    is "Copyright (C) 2002, 2003 Gerd Moellmann" with BSD-style
    permissions. [ISTR some controversy about that at the time,
    something about Germany (where Gerd lives) not recognizing
    the concept of "dedicating to the public domain".]

Some of the non-core bits have specific more-restrictive copyrights, e.g.:

  - The SOAR benchmarks are "Copyright (c) 1985 Xerox Corporation. ...
    [use] is permitted for non-commercial research purposes, and
    it may be copied only for that use." [That's the only such
    "non-commercial" limitation I know of.]

  - The files "motif/{lisp,server}/timer-support.{lisp,c}" in the
    optional Motif-based debugger module are "Copyright (C) Marco
    Antoniotti 1994", with neither a reservation of rights nor
    any use permissions, so that one is... questionable. [Marco?
    Are you willing to make this an MIT- or BSD-style copyright?]


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: jkc
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <pan.2006.07.30.20.10.15.40244@makewavs.com>
On Sun, 30 Jul 2006 04:02:15 -0400, Ken Tilton wrote:

> 
> Because CMUCL is Turing equivalent? <sigh> The poor guy has already 
> spent more in time-dollars on this one bug than the cost of a pro 
> license to Lispworks:
> 
>> I've spent hours parsing comp.lang.lisp and various UFFI, CFFI
>> documents, the CMUCL manual, trying to figure out how to read a binary
>> floating point file in Lisp off and on for the last week without
>> success.
> 
> You want to upgrade his waste to an enterprise license for ACL?
> 
> kt (LMAO because all this time I thought "how could a 'reading binary' 
> thread in any way relate to my only interest here, viz. the outing of 
> the FSF as the biggest waste of energy on the planet?". k

It has not been a waste for me at all. I've learned countless things in
the process of the search - the same as you all did when you were getting
started with a new language, I'll warrant. 

-jkc
From: Nathan Baum
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <Pine.LNX.4.64.0607302144400.17336@localhost>
On Sun, 30 Jul 2006, Ken Tilton wrote:
> Pascal Bourguignon wrote:
>>  Duane Rettig <·····@franz.com> writes:
>>
>> 
>> > jkc <·······@makewavs.com> writes:
>> > 
>> > 
>> > > On Fri, 28 Jul 2006 13:52:00 -0700, Duane Rettig wrote:
>> > > 
>> > > > > Type-error in KERNEL::OBJECT-NOT-DOUBLE-FLOAT-ERROR-HANDLER:
>> > > > >    #\Null is not of type DOUBLE-FLOAT
>> > > > 
>> > > > You must be using a simple-streams implementation from another lisp.
>> > > > Allegro CL doesn't have a KERNEL package.
>> > > > 
>> > > > What you're seeing above is a bug; you should report it to that
>> > > > lisp's support team.
>> > > 
>> > > I'm using CMUCL (I thought I mentioned that). If this is indeed a bug, 
>> > > I
>> > > will see what I can do to let them know about it. 
>> > 
>> > Or fix it yourself.  It is, after all, free software - it should be
>> > easy :-)
>>
>>
>>  s/easy/possible/
>>
>>  We never claimed it would be easy, but that it'd be possible.
>> 
>
> Because CMUCL is Turing equivalent? <sigh> The poor guy has already spent 
> more in time-dollars on this one bug than the cost of a pro license to 
> Lispworks:

Really? What's the exchange rate between time-dollars and real dollars 
these days?

>>  I've spent hours parsing comp.lang.lisp and various UFFI, CFFI
>>  documents, the CMUCL manual, trying to figure out how to read a binary
>>  floating point file in Lisp off and on for the last week without
>>  success.
>
> You want to upgrade his waste to an enterprise license for ACL?
>
> kt (LMAO because all this time I thought "how could a 'reading binary' thread 
> in any way relate to my only interest here, viz. the outing of the FSF as the 
> biggest waste of energy on the planet?". k

Riiight. Because CMUCL is made by the FSF...
From: Ken Tilton
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <XKazg.10721$UY2.5513@fe11.lga>
Nathan Baum wrote:
> On Sun, 30 Jul 2006, Ken Tilton wrote:
> 
>> Pascal Bourguignon wrote:
>>
>>>  Duane Rettig <·····@franz.com> writes:
>>>
>>>
>>> > jkc <·······@makewavs.com> writes:
>>> > > > > On Fri, 28 Jul 2006 13:52:00 -0700, Duane Rettig wrote:
>>> > > > > > > Type-error in KERNEL::OBJECT-NOT-DOUBLE-FLOAT-ERROR-HANDLER:
>>> > > > >    #\Null is not of type DOUBLE-FLOAT
>>> > > > > > > You must be using a simple-streams implementation from 
>>> another lisp.
>>> > > > Allegro CL doesn't have a KERNEL package.
>>> > > > > > > What you're seeing above is a bug; you should report it 
>>> to that
>>> > > > lisp's support team.
>>> > > > > I'm using CMUCL (I thought I mentioned that). If this is 
>>> indeed a bug, > > I
>>> > > will see what I can do to let them know about it. > > Or fix it 
>>> yourself.  It is, after all, free software - it should be
>>> > easy :-)
>>>
>>>
>>>  s/easy/possible/
>>>
>>>  We never claimed it would be easy, but that it'd be possible.
>>>
>>
>> Because CMUCL is Turing equivalent? <sigh> The poor guy has already 
>> spent more in time-dollars on this one bug than the cost of a pro 
>> license to Lispworks:
> 
> 
> Really? What's the exchange rate between time-dollars and real dollars 
> these days?

First PB tries wo wipe all our hard drives, now you want me to have a 
zero divide error....The Savages of FSF?

:)

kt

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Rob Warnock
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <KJudnVKOyrJQwVDZnZ2dnUVZ_oidnZ2d@speakeasy.net>
Nathan Baum  <···········@btinternet.com> wrote:
+---------------
| Riiight. Because CMUCL is made by the FSF...
+---------------

Please, that's an insult to CMUCL!! As Pascal pointed out,
CMUCL was not & is not an FSF project, nor is it GPL'd
[thank goodness!].


-Rob

p.s. See my quick informal survey of CMUCL's copyright status
in a parallel reply.

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: jkc
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <pan.2006.07.30.15.08.21.837460@makewavs.com>
On Fri, 28 Jul 2006 13:52:00 -0700, Duane Rettig wrote:
> It works fine in Allegro CL (for which you can download the Express
> Edition for free):

The problem for me with becoming dependent on Allegro CL is that I find
the licensing restrictions on the potential sale of my products
objectionable. Otherwise I would just buy it. 

-jkc
From: Marcin 'Qrczak' Kowalczyk
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <87k65ybtgp.fsf@qrnik.zagroda>
James Bielman <·······@jamesjb.com> writes:

> (defcfun ("fread" %fread) :long
>   (ptr :pointer)
>   (size :long)
>   (nmemb :long)
>   (stream :pointer))

This is not portable: the 2nd and 3rd argument of fread and its result
have C type size_t, not long.

For example on 64-bit Windows long has 32 bits but size_t has 64 bits.
Ignoring even signedness mismatch.

-- 
   __("<         Marcin Kowalczyk
   \__/       ······@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/
From: jkc
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <pan.2006.07.28.12.06.11.193176@makewavs.com>
On Thu, 27 Jul 2006 23:58:46 +0200, Marcin 'Qrczak' Kowalczyk wrote:

> James Bielman <·······@jamesjb.com> writes:
> 
>> (defcfun ("fread" %fread) :long
>>   (ptr :pointer)
>>   (size :long)
>>   (nmemb :long)
>>   (stream :pointer))
> 
> This is not portable: the 2nd and 3rd argument of fread and its result
> have C type size_t, not long.
> 
> For example on 64-bit Windows long has 32 bits but size_t has 64 bits.
> Ignoring even signedness mismatch.

So how would I make it portable? So far as I know, there isn't a :size_t
From: Greg Menke
Subject: Re: How to read a binary floating-point file?
Date: 
Message-ID: <m3odvb3ceh.fsf@athena.pienet>
"jkc" <·······@makewavs.com> writes:

> I've spent hours parsing comp.lang.lisp and various UFFI, CFFI
> documents, the CMUCL manual, trying to figure out how to read a binary
> floating point file in Lisp off and on for the last week without
> success. I'm hoping someone here will help me.
> 

http://darcs.informatimago.com/local/darcs/public/lisp/common-lisp/heap.lisp

Scroll down to "gen-ieee-encoding"

Its not doing vector IO but it does work pretty well and no need for
UFFI/CFFI.  You can pull out the float stuff by itself to work on.

Gregm