IRC channel logs

2021-03-30.log

back to list of logs

<leoprikler>jlicht: guile-json/guile-yaml come to mind, but on the high level you're on your own i fear
<wheeler>Having trouble following the examples from https://www.gnu.org/software/guile/manual/html_node/Symbol-Keys.html
<wheeler>In my REPL, I get an error for assq-set!
<wheeler>when running (assq-set! car1-properties 'seat-colour 'black)
<wheeler>Wrong type argument in position 1 (expecting mutable pair): (seat-colour . red)
<wheeler>Where did I go wrong?
<wheeler>Is this because I'm running v2.2.7 and not 3.0.X?
<wheeler>OK, it's not the version. Getting the same result in v3.0.5
<wheeler>Am I missing an rnrs?
<flatwhatson>Seems to be picky about how the pairs are created. If you use assq-set! to add the initial value, and then to modify it, it seems to work?
<wheeler>flatwhatson: That's right. It works if I set values manually with assq-set! for initial value but not if I use define or set! for the whole alist.
<wheeler>strange
<wheeler>but the examples at https://www.gnu.org/software/guile/manual/html_node/Symbol-Keys.html *should* work.... or at least they seem very sensible :D
<flatwhatson>(define props '((foo . bar)))
<flatwhatson>(set! props (assq-set! props 'foo 'baz)) ; fails
<flatwhatson>(set-cdr! (assq 'foo props) 'baz) ; works
<wheeler>Sounds good -- I'll use set-cdr! and assq for now
<wheeler>Thanks, flatwhatson!
<flatwhatson>I agree the examples should work. Guess it's a bug?
<wheeler>Must be.
<wheeler>Perhaps the examples were from an older version
<daviid>wheeler: somewhere in guile's evoution, '(a . b) becomes immutable, as opposed to (cons 'a 'b), this is a manual bug - this will work
<daviid>just a min
<daviid>(define car1-properties `(,(cons 'colour 'red) ,(cons 'transmission 'manual)))
<daviid>(assq-set! car1-properties 'colour 'black)
<flatwhatson>But why does the set-cdr! version work?
<daviid>on a immutable pair, that soundfs like a bug, not sure this will work using 3.0 (i was testing the above using 2.2.7
<flatwhatson>Above is from 3.0.5
<wheeler>daviid: The quasi-quote example also worked in 3.0
<daviid>flatwhatson: i meant to say i did test what i wrote using 2.2.7
<flatwhatson>Interesting! Confirmed set-cdr! on immutable pair fails in 2.2.7, but doesn't fail on 3.0.5.
<flatwhatson>Weird thing is that assq-set! calls scm_set_cdr_x, which is aka set-cdr!. When called from C, it errors (correctly), but called from scheme, it works.
<leoprikler>flatwhatson: I believe in some of these cases the pair isn't actually immutable (that immutability is gained through compilation)
***apteryx_ is now known as apteryx
***drakonis- is now known as drakonis
<dsmith-work>Tuesday Greetings, Guilers
<lloda>RhodiumToad: thx re primitive-exit
***Noisytoot is now known as noisytoot[x]
***noisytoot[x] is now known as Noisytoot
<MeRaZi>greetings everybody