guile-user
[Top][All Lists]
Advanced

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

Re: Surprising behavior of eq?


From: tomas
Subject: Re: Surprising behavior of eq?
Date: Sun, 20 Sep 2020 18:18:21 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Sun, Sep 20, 2020 at 05:37:45PM +0200, Zelphir Kaltstahl wrote:
> Hello John, hello Stefan!

[...]

> Of course SO is not a standard. Either it is simply wrong, or I
> misunderstood "primitive values" in that phrase. I thought: "Ah strings
> are a primitive value, so eqv? should work in all cases when comparing
> strings." However, this has been debunked.

Strings are mutable in Guile, so probably not what's called "primitive
values":

  scheme@(guile-user)> (define str (string-copy "the quick brown fox"))
  scheme@(guile-user)> (string-set! str 6 #\a)
  scheme@(guile-user)> str
  $3 = "the quack brown fox"

But string literals bark at you if you try to mutate them (that's why
I slyly created that one with `string-copy'):

  scheme@(guile-user)> (define str "the quick brown fox")
  scheme@(guile-user)> (string-set! str 6 #\a)
  ice-9/boot-9.scm:1669:16: In procedure raise-exception:
  string is read-only: "the quick brown fox"

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

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