chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] regression - probably in let*


From: Jörg F. Wittenberger
Subject: Re: [Chicken-hackers] regression - probably in let*
Date: Sat, 04 Jul 2015 12:10:59 +0200
User-agent: Mozilla/5.0 (X11; Linux armv7l; rv:31.0) Gecko/20100101 Icedove/31.7.0

Am 04.07.2015 um 06:53 schrieb Evan Hanson:
> Hi Jörg,
> 
> It's as the others say: the scrutinizer differentiates between true and
> false, so your assignment of one over the other breaks the assumptions
> that strict-types implies.

I understood that already.  Thanks for the explanation anyway.

> You'd have similar problems if you `set!` a
> fixnum to a float, or an input-port to an output-port, and so on. With
> strict-types, a variable should not change from any one of the types
> listed on http://wiki.call-cc.org/man/4/Types to any other.

For the float vs. fixnum case, I had been less surprised.  But the type
rules are pretty clear.   "false" and "true" are just in so far actually
an unintuitive case as Felix pointed out.

> That said, it would be useful if `:` or `the` could override inferred
> types for this purpose, so that one could safely say, for example:
> 
>     (let ((a (the boolean #t)))
>       ...
>       (set! a #f)
>       ...
>       (if a 'either 'or))
> 
> (This might also make no sense; I'm not sure just now.)

That's actually possible and I must admit that I did so quite some times
when I had to have a variable changing type.

However my source goes through some trick (which might no longer be
necessary, I never re-checked).  This xthe syntax does the trick for me:


(: xthe-identity-inline (* --> *))
(define-inline (xthe-identity-inline x) x)
(define-syntax xthe
  (syntax-rules ()
    ((_ type val) (the type (xthe-identity-inline val)))))




reply via email to

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