Martin Ward | 14 Jul 2009 08:26
Picon

Four problems with Scheme 48 1.8


(1) Compiling with gcc version 4.4.0 gives an error on "make test":

FAILURES:
Test case *3 [misc-big-tests] FAILED:
From expression (* 47123 46039) EXPECTED value 2169495797 of 2169495797
INSTEAD got -2125471499

'(#{Check-failure #{Test-case *3} (actual (* 47123 46039) -2125471499) 
(expected 2169495797 2169495797) #{Procedure 983 (equal? in 
scheme-level-1)}})

Compiling with gcc 4.0.1 seems to work OK.

(2) I cannot figure out how to define a macro such as:

(defmacro substr (str from . rest)
  (if (null? rest)
      ; two argument form of substr:
      `(let ((s ,str))
         (substring s ,from (string-length s)))
      ; three argument form of substr:
      `(substring ,str ,from (+ ,from , <at> rest))))

SCM and the Hobbit compiler support defmacro, Gambit can define defmacro as:

(define-macro (defmacro name args . body)
  `(define-macro (,name , <at> args) , <at> body))

(3) scheme48 won't accept ++ as a symbol name for some reason:
(Continue reading)

Andreas Rottmann | 14 Jul 2009 14:09
Picon
Picon
Gravatar

Re: Four problems with Scheme 48 1.8

Martin Ward <martin <at> gkc.org.uk> writes:

> (1) Compiling with gcc version 4.4.0 gives an error on "make test":
>
> FAILURES:
> Test case *3 [misc-big-tests] FAILED:
>>From expression (* 47123 46039) EXPECTED value 2169495797 of 2169495797
> INSTEAD got -2125471499
>
> '(#{Check-failure #{Test-case *3} (actual (* 47123 46039) -2125471499) 
> (expected 2169495797 2169495797) #{Procedure 983 (equal? in 
> scheme-level-1)}})
>
> Compiling with gcc 4.0.1 seems to work OK.
>
I'll leave that one to more knowledgeable people than me.

>
> (2) I cannot figure out how to define a macro such as:
>
> (defmacro substr (str from . rest)
>   (if (null? rest)
>       ; two argument form of substr:
>       `(let ((s ,str))
>          (substring s ,from (string-length s)))
>       ; three argument form of substr:
>       `(substring ,str ,from (+ ,from , <at> rest))))
>
Scheme48 doesn't have `define-macro'-style macros (which are a bad idea
anyway, as they are inherently unhygienic); you'd either have to use
(Continue reading)

Michael Sperber | 15 Jul 2009 11:39
Picon

Re: Four problems with Scheme 48 1.8


Martin Ward <martin <at> gkc.org.uk> writes:

> (1) Compiling with gcc version 4.4.0 gives an error on "make test":
>
> FAILURES:
> Test case *3 [misc-big-tests] FAILED:
>>From expression (* 47123 46039) EXPECTED value 2169495797 of 2169495797
> INSTEAD got -2125471499
>
> '(#{Check-failure #{Test-case *3} (actual (* 47123 46039) -2125471499) 
> (expected 2169495797 2169495797) #{Procedure 983 (equal? in 
> scheme-level-1)}})
>
> Compiling with gcc 4.0.1 seems to work OK.

On what platform are you doing this?

--

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

Martin Ward | 15 Jul 2009 11:40
Picon

Re: Four problems with Scheme 48 1.8


Thanks for your message!

On Tuesday 14 Jul 2009 13:09, you wrote:

> > (2) I cannot figure out how to define a macro such as:
> >
> > (defmacro substr (str from . rest)
> >   (if (null? rest)
> >       ; two argument form of substr:
> >       `(let ((s ,str))
> >          (substring s ,from (string-length s)))
> >       ; three argument form of substr:
> >       `(substring ,str ,from (+ ,from , <at> rest))))
>
> Scheme48 doesn't have `define-macro'-style macros (which are a bad idea
> anyway, as they are inherently unhygienic); you'd either have to use
> syntax-rules, or use explicit-renaming macros[0]. For the above example,
> I syntax-rules suffices:
>
> (define-syntax substr
>   (syntax-rules ()
>     ((substr str from)
>      (let ((s str))
>        (substring s from (string-length s))))
>     ((substr str from count)
>      (substring str from (+ from count)))))

I was hoping that there would be a simple way to define defmacro using
define-syntax and syntax-rules, but I can't find one.
(Continue reading)

Taylor R Campbell | 15 Jul 2009 16:04
Favicon

Re: Four problems with Scheme 48 1.8

   Date: Wed, 15 Jul 2009 11:40:24 +0200
   From: Martin Ward <martin <at> gkc.org.uk>

   I was hoping that there would be a simple way to define defmacro using
   define-syntax and syntax-rules, but I can't find one.
   (There is something which lookd promising in SLIB, but I couldn't
   get it to work).

DEFMACRO is a bug.  Some Schemes attempt to mask the bug by providing
DEFMACRO, but fortunately for you Scheme48 doesn't do that.

Anyway, why write a macro?  Your macro -- as defined -- exhibits a
property that is at least confusing and that one might consider to be
a bug: (SUBSTR <string> <from> <count>) evaluates the expression
<from> twice.  Aside from that, though, SUBSTR macro does nothing that
a procedure couldn't do:

(define (substr string from . count)
  (substring string
             from
             (if (pair? count)
                 (+ from (car count))
                 (string-length string))))

Helmut Eller | 16 Jul 2009 08:56
Picon

Re: Four problems with Scheme 48 1.8

* Martin Ward [2009-07-15 11:40+0200] writes:

> I was hoping that there would be a simple way to define defmacro using
> define-syntax and syntax-rules, but I can't find one.

With explicit-renaming macros you could define defmacro as:

(define-syntax defmacro 
  (syntax-rules ()
    ((defmacro name args body ...)
     (define-syntax name 
       (lambda (form rename compare)
	 (apply (lambda args body ...)
		(cdr form)))))))

(defmacro when (test . body) `(cond (,test . ,body)))

Ignore the renaming junk and viola: defmacro.

Helmut

Taylor R Campbell | 16 Jul 2009 21:09
Favicon

Re: Four problems with Scheme 48 1.8

This is an internal compiler error (although it is not clear from the
message) which is unrelated to the bibop collector, as far as I know.
The compiler imposes a limit of 2^16 on something, although why it is
2^16 and not about 2^24 I don't know; I think it probably should be
2^24.  If I change it to be this, Scheme48 at least compiles ALL.scm,
although that file has other problems -- references to undefined
variables such as FILE-EXISTS?, lexical syntax errors such as leading
at-signs ( <at> ) in names, &c.

John Clements | 25 Jul 2009 15:33
Gravatar

Register now! for the Scheme Workshop

           2009 Workshop on Scheme and Functional Programming
        Coordinated with the Symposium in Honor of Mitchell Wand

                             August 22, 2009
                      Boston, Massachusetts, USA
                   http://www.schemeworkshop.org/2009

                         CALL FOR PARTICIPATION

To the delight of all and sundry, the 2009 Scheme and
Functional Programming Workshop will be held on August 22nd
at Northeastern University, and it is a signal honor for me
to be able to invite YOU to the WORLD'S FOREMOST WORKSHOP
on the marvelous Scheme language, and to present a program
PACKED with contributions from familiar faces and new ones,
certain to amaze, delight, and edify. Lend us your ears,
and we will widen the space between them.

- John Clements

IMPORTANT DATES

August 11, 2009 - Registration deadline
August 22, 2009 - Workshop on Scheme and Functional Programming
August 23-24, 2009 - Symposium in Honor of Mitchell Wand:
    http://www.ccs.neu.edu/events/wand-symposium

VENUE

Northeastern University
(Continue reading)

Michael Sperber | 29 Jul 2009 17:47
Picon

Re: Four problems with Scheme 48 1.8

Martin Ward <martin <at> gkc.org.uk> writes:

> (1) Compiling with gcc version 4.4.0 gives an error on "make test":
>
> FAILURES:
> Test case *3 [misc-big-tests] FAILED:
>>From expression (* 47123 46039) EXPECTED value 2169495797 of 2169495797
> INSTEAD got -2125471499
>
> '(#{Check-failure #{Test-case *3} (actual (* 47123 46039) -2125471499) 
> (expected 2169495797 2169495797) #{Procedure 983 (equal? in 
> scheme-level-1)}})
>
> Compiling with gcc 4.0.1 seems to work OK.

This appears to be a bug in gcc 4.4, I'm afraid.  The negative result is
an intermediate result of an overflow: The VM contains tests for this
that handle the situation, but gcc 4.4 with -O2 elides the test.  So
your options are to either compile with gcc 4.0.1 or without -O2.

I haven't found a way to extract a smaller code snippet from the VM that
exhibits the problem - I'd be happy to hear suggestions on how to best
report this bug to the gcc people.

--

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

Michael Sperber | 30 Jul 2009 10:42
Picon

Re: Four problems with Scheme 48 1.8


Michael Sperber <sperber <at> deinprogramm.de> writes:

> Martin Ward <martin <at> gkc.org.uk> writes:
>
>> (1) Compiling with gcc version 4.4.0 gives an error on "make test":
>>
>> FAILURES:
>> Test case *3 [misc-big-tests] FAILED:
>>>From expression (* 47123 46039) EXPECTED value 2169495797 of 2169495797
>> INSTEAD got -2125471499
>>
>> '(#{Check-failure #{Test-case *3} (actual (* 47123 46039) -2125471499) 
>> (expected 2169495797 2169495797) #{Procedure 983 (equal? in 
>> scheme-level-1)}})
>>
>> Compiling with gcc 4.0.1 seems to work OK.
>
> This appears to be a bug in gcc 4.4, I'm afraid.  

Scratch that and substitute "interesting interpretation of the ANSI C
standard."  The attached patch (which is in the development code) works
around the problem.

--

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla
changeset:   1289:ab92a31cec79
(Continue reading)


Gmane