Re: string is read-only
Il giorno 3 agosto 2022, alle ore 13:36, Damien Mattei ha scritto: >On Wed, Aug 3, 2022 at 12:59 PM Maxime Devos wrote: >> >> (My unverified hypothesis on why you aren't seeing an error here.) >> >> >> it would be a big change and very strange :-O if the few lines of code >below in scheme returned an error on lists: >but no restrictions with lists in Guile: >scheme@(guile-user)> (define lst '(1 2 3)) >scheme@(guile-user)> (set-car! lst 7) >scheme@(guile-user)> lst >(7 2 3) This is illegal scheme. The consequences of executing it are undefined. It's unfortunate that because of implementation limitations many schemes do not detect this error. >it is interesting ,at the end of page it says too that modifying quoted >litteral should create an error :-O It's how all Lisps, including guile, works. So, yes, if one is interested in these languages, this is interesting knowledge :)
Re: cond clause does not allow definitions
On Wed, May 22, 2024 at 10:08 PM Jeronimo Pellegrini wrote: > A: (cond (#t (define x 7) x)) > B: (cond (else (define x 7) x)) > > | system | A | B | > |-|---|---| > | Bigloo | 7 | 7 | > | Biwa| 7 | 7 | > | Chez| error | 7 | > | Chibi | error | 7 | In chez: > (cond (else (define x 7) x)) 7 > x 7 which looks like a bug to me. You may check if x is defined outside of the cond expression in the other implementations which do not raise an error too?
Re: cond clause does not allow definitions
On Thu, May 23, 2024 at 4:25 PM Damien Mattei wrote: > On Thu, May 23, 2024 at 12:37 AM Jeronimo Pellegrini wrote: >> On 2024-05-22 18:07, Pierpaolo Bernardi wrote: >> > In chez: >> > >> >> (cond (else (define x 7) x)) >> > 7 >> >> x >> > 7 >> > >> > which looks like a bug to me. > yes i spent many hours debugging to understand why > (cond (else (define y 7) y)) worked and not (cond (#t (define x 7) x)) I had and explanation from Jamie Taylor. The implementations which behave like Chez, are probably using the example definition of the cond syntax given in appendix B of the R6 report, which expands (cond (else result1 result2 ...)) into (begin result1 result2 ...). Given the splicing nature of begin, when the cond is in a context valid for definitions we have the weird result above. https://github.com/cisco/ChezScheme/issues/835