chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] [PATCH] Less type smashing


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Less type smashing
Date: Wed, 13 Sep 2017 08:52:02 +0200
User-agent: NeoMutt/20170113 (1.7.2)

On Tue, Sep 12, 2017 at 10:20:24AM +0200, LemonBoy wrote:
> Hello hackers,
> after debugging some code I noticed the compiler was smashing the type for 
> some
> list I had defined via `define-constant`. That's not needed since the 
> constants
> aren't exported nor they are modifiable so here's a patch to make the
> scrutinizer aware of that.

I think this patch is too dangerous.  The reason is that the compiler does
absolutely nothing to prevent mutation of "constants":

$ cat test.scm
(define-constant foo '(a b c))
(set-car! foo 1)
(print foo)

(set-cdr! foo 2)
(print foo)

$ csc -O3 test.scm
$ ./test
(1 b c)
(1 . 2)

Now I'd agree your patch would be a good thing, but _only_ if we can make
the compiler enforce immutability of constant objects (which can't be
done in general, AFAIK).

Cheers,
Peter

Attachment: signature.asc
Description: PGP signature


reply via email to

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