[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Protect against mutation
From: |
Christian Kellermann |
Subject: |
Re: [Chicken-users] Protect against mutation |
Date: |
Sun, 28 Dec 2014 13:12:03 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
* Bahman Movaqar <address@hidden> [141228 13:00]:
> On 12/27/2014 05:30 PM, Christian Kellermann wrote:
> > * Bahman Movaqar <address@hidden> [141227 13:51]:
> >> Consider the following snippet:
> >>
> >> (use srfi-1)
> >> (define (mutator lis n) (set! (first lis) n) lis)
> >> (define ll (list 1 2 3 4))
> >> (mutator (cdr lis) 100)
> >> (equal? (second? lis) 100) --> #t
> >>
> >> Is there anyway to protect "lis" from mutation? TIA,
> > No, you would need immutable list objects, which an egg provides
> > IIRC.
> >
>
> Thanks for the hint --I was hoping this to be the default behaviour.
> I guess, for me, setting a personal ban on "set!" is easier than using
> a new vocabulary.
Depending on your use case you should consider an immutable environment
when calling eval?
--
May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.