Mikhail S. Shevchuk | 2 May 2006 19:19

Scheme48 on linux & matrix.scm

Hi,
I've downloaded this package somewhere on web and tried to load it in 
Scheme48. I've got some "obvious" errors there, so I fixed them. I think this 
package was designed for mit-scheme. But after fixing obvious errors there is 
one more wich I can't understand and fix. Intepreter just outputs on ",load 
matrix.scm":
Warning: undefined variables
         #{Package 221 user}
         error
         format
         (&warning)
> 

Where to find bug? I've attached modified matrix.scm to this letter.
Thanks for developing s48! :)
;;; matrix.ss (0.1)
;;;
;;; Matrix manipulation routines.
;;;
;;; Winter Quarter 1992
;;; Rose-Hulman Institute of Technology
;;; Todd R. Eigenschink
;;;
;;; My original ideas for which routines to include were borrowed
;;; from a matrix package written by Joe Maruszewski.  I started
;;; from scratch on almost all the routines, writing them, and
;;; then adding every error check I could think of.  I have added
;;; a large number of routines that I thought were missing (or that
(Continue reading)

Michael Sperber | 2 May 2006 19:23
Picon

Re: Scheme48 on linux & matrix.scm


"Mikhail S. Shevchuk" <mico <at> sibmail.com> writes:

> I've downloaded this package somewhere on web and tried to load it in 
> Scheme48. I've got some "obvious" errors there, so I fixed them. I think this 
> package was designed for mit-scheme. But after fixing obvious errors there is 
> one more wich I can't understand and fix. Intepreter just outputs on ",load 
> matrix.scm":
> Warning: undefined variables
>          #{Package 221 user}
>          error
>          format
>          (&warning)

The code uses procedures called `error' and `format', which are
MIT-Scheme-specific.  For `error', the version in the `signals'
package should be a close-enough approximation.  Do

,open signals

to pull that in.

As to `format', it's a bit more involved.  Do

,open formats

and change this line:

			     (format "~a" (matrix-ref a i j))))))

(Continue reading)

Mikhail S. Shevchuk | 4 May 2006 14:13

Pretty decrementing

Hello,

The question why can't I write this:
(define (1- x)
  (- x 1))
but this works well:
(define (1+ x)
  (+ x 1))

The output is:
Error: unsupported number syntax
       "1-"
       (&i/o-port-error (port . #{Input-port #{Input-channel "standard 
input"}}))
       (&i/o-read-error (port . #{Input-port #{Input-channel "standard 
input"}}))

Thanks,
Mikhail

Michael Sperber | 4 May 2006 14:55
Picon

Re: Pretty decrementing


[PS: If you post to scheme48 at s48 dot org directly rather than
s48-info, more can look at the problem earlier.]

"Mikhail S. Shevchuk" <mico <at> sibmail.com> writes:

> Hello,
>
> The question why can't I write this:
> (define (1- x)
>   (- x 1))
> but this works well:
> (define (1+ x)
>   (+ x 1))

That's because `1-' isn't a valid identifier as per the Scheme
standard.  `1+' also isn't, but the fact that Scheme 48 doesn't reject
it is a concession to SICP (which uses `1+', but not `1-'.)  I suspect
it was only used in the first edition though, and we might take it out
now.  So I recommend against using either name in a Scheme program.

--

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla

Mikhail S. Shevchuk | 7 May 2006 11:16

Matrix package

Hi,

I am trying to fix matrix.scm (by Todd R. Eigenschin) and to make it work on 
scheme48. After some fixes, it loads on scheme48 and even some basic 
operations can be done. But I can't fix pretty-print-matrix procedure, the  
interpreter outputs elements of matrix in not a very pretty way and the 
write: Error: vm-exception
       wrong-type-argument
       (string-length #f)

Well, it is actually so. There is a "(string-length (matrix-ref s i j))" where 
argument is just an integer for example. I don't know what implementation 
author used, and I can't ask him, because this package is dated by 1992.
But may be there are some thoughts how to fix this procedure. matrix.scm is 
attached. (some structures are needed for correct work: signals, formats)

Regards,
Mikhail
;;; matrix.ss (0.1)
;;;
;;; Matrix manipulation routines.
;;;
;;; Winter Quarter 1992
;;; Rose-Hulman Institute of Technology
;;; Todd R. Eigenschink
;;;
;;; My original ideas for which routines to include were borrowed
;;; from a matrix package written by Joe Maruszewski.  I started
(Continue reading)

RT Happe | 7 May 2006 12:35
Picon

Re: Matrix package

Mikhail S. Shevchuk wrote:

> Well, it is actually so. There is a "(string-length (matrix-ref s i 
> j))" where
> argument is just an integer for example. I don't know what 
> implementation

You could use something like

     (define (display-string-length x)
       (string-length (format #f "~a" x)))

rt

Emilio Lopes | 7 May 2006 14:39
Picon

Re: Pretty decrementing

Michael Sperber writes:

> "Mikhail S. Shevchuk" <mico <at> sibmail.com> writes:

>> Hello,
>> 
>> The question why can't I write this:
>> (define (1- x)
>> (- x 1))
>> but this works well:
>> (define (1+ x)
>> (+ x 1))

> That's because `1-' isn't a valid identifier as per the Scheme
> standard.  `1+' also isn't, but the fact that Scheme 48 doesn't reject
> it is a concession to SICP (which uses `1+', but not `1-'.)  I suspect
> it was only used in the first edition though, and we might take it out
> now.  So I recommend against using either name in a Scheme program.

To the OP: People usually use `add1' and `sub1' in Scheme, but I've
also seen `inc' and `dec'.

--

-- 
Emílio C. Lopes
Munich, Germany

Taylor R. Campbell | 7 May 2006 21:37
Favicon

Re: Matrix package

   Date: Sun, 07 May 2006 11:16:58 +0200
   From: "Mikhail S. Shevchuk" <mico <at> sibmail.com>

   Hi,

   I am trying to fix matrix.scm (by Todd R. Eigenschin) and to make it work on 
   scheme48. After some fixes, it loads on scheme48 and even some basic 
   operations can be done. But I can't fix pretty-print-matrix procedure, the  
   interpreter outputs elements of matrix in not a very pretty way and the 
   write: Error: vm-exception
          wrong-type-argument
          (string-length #f)

This is probably because the matrix was constructed with:

  (make-matrix rows cols
               (lambda (i j)
                 (format #t "~a" (matrix-ref a i j))))

(FORMAT #T ...) returns an unspecified value after writing the
formatted output to the current output port.  I suspect that you
probably want to use (FORMAT #F ...) here.

Taylor R. Campbell | 9 May 2006 02:07
Favicon

networking interface, and incidentally access to C data from Scheme

I vaguely recall hearing some time ago that there were plans to clean
up scsh's networking interface and to implement it for Scheme48.  Has
there been any progress on this front?

A couple of months ago I wrote my own implementation of most of scsh's
networking interface, and Brian Templeton implemented the network
database interface, for Scheme48 1.3.  I've put a Darcs repository up
at

  <http://mumble.net/~campbell/darcs/s48-network/>;

it also relies on a utility for access to C data structures and
constants from Scheme, a Darcs repository of which is at

  <http://mumble.net/~campbell/darcs/s48-grovel/>.

Martin Gasbichler has cautioned me that this approach may result in
heap images with system-specific data; this is not a minor concern,
but it was convenient at the time to build it the way I did.

David Van Horn | 9 May 2006 21:51
Picon

Re: Pretty decrementing

Michael Sperber wrote:
> That's because `1-' isn't a valid identifier as per the Scheme
> standard.  `1+' also isn't, but the fact that Scheme 48 doesn't reject
> it is a concession to SICP (which uses `1+', but not `1-'.)  I suspect
> it was only used in the first edition though, and we might take it out
> now.  So I recommend against using either name in a Scheme program.

Indeed, the second edition of SICP uses `inc' (page 58) instead of `1+'.

David


Gmane