[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Protect against mutation
From: |
Bahman Movaqar |
Subject: |
Re: [Chicken-users] Protect against mutation |
Date: |
Sun, 28 Dec 2014 15:30:35 +0330 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
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.
--
Bahman Movaqar
http://BahmanM.com - https://twitter.com/bahman__m
https://github.com/bahmanm - https://gist.github.com/bahmanm
PGP Key ID: 0x6AB5BD68 (keyserver2.pgp.com)