chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] testcase -strict-types


From: Peter Bex
Subject: Re: [Chicken-hackers] testcase -strict-types
Date: Mon, 25 Mar 2013 10:19:35 +0100
User-agent: Mutt/1.4.2.3i

On Mon, Mar 25, 2013 at 09:58:32AM +0100, Jörg F. Wittenberger wrote:
> Though in a way the explanation is correct.  -strict-types assumes
> '() to be null from the initialization.  Short of a way to declare
> the type of foobar as (list-of <whatever>) this fails when it's used
> as the initial and correct value of type (list-of <whatever>) with
> zero length.

This seems to be a bug, unless I'm mistaken.  Could you please file a
ticket for this?  Thanks!

> What the optimizer should do is to see into the doloop and notice
> the ambiguous type null being refined to a list.

No, it shouldn't, because you've declared strict types.  That explicitly
tells it not to do this AFAICT.

I'd simply change the code to be functional, this eliminates the
problems you're having.  All this messing around with set! is
needlessly confusing (for the person reading the code as well as
the scrutinizer).

(module
 foo
 (bar)
 (import scheme chicken)

 (define (bar . args)
   (let ((foobar '()))
     (do ((rest args (cddr rest))
          (foobar '() (if (eq? (car rest) #:foobar)
                          (cons (cadr rest) foobar)
                          foobar)))
         ((null? rest)
          (if (null? foobar)
              'gaga
              foobar))
       (if (null? (cdr rest))
           (error (car rest))))))

)

(import foo)

(display (bar #:foobar 42))
(newline)


Cheers,
Peter
-- 
http://www.more-magic.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]