IRC channel logs


back to list of logs

<cky>ArneBab_: Just one small comment. It should be "a SRFI" and not "an SRFI".
<cky>See the bottom item in
<nalaginrut>ArneBab_: well, you see the highlight
<nalaginrut>syntax highlight
***ceverett is now known as _zxq9_
<slucx>(string-set! "hello" 0 #\\A) => string is read-only
<slucx>and why?
<slucx>- Scheme Procedure: string-set! str k chr
<slucx> Store CHR in element K of STR and return an unspecified value. K
<slucx> must be a valid index of STR.
<nalaginrut>slucx: because literal string is immutable
<nalaginrut>slucx: you may generate a string with make-string
<slucx>I got it, thanks nalaginrut
<slucx>It's like C's string and char array
<nalaginrut>np ;-)
<slucx>nalaginrut: I make a string with length 1 use (define ss (make-string
<nalaginrut>sneek: later tell slucx because string-cope does a new copy
<mark_weaver>slucxx: string-copy takes only one string argument, and allocates a fresh new copy. it doesn't copy into an existing string.
<mark_weaver>e.g. (string-copy "hello") returns a copy of "hello" that you can now mutate
<slucxx>mark_weaver: I got it, thank you ;-)
<sneek>slucxx, you have 1 message.
<sneek>slucxx, nalaginrut says: because string-cope does a new copy
<mark_weaver>slucxx: if you pass a string as the second argument, it should raise an error. it does for me, anyway. what version of guile are you using?
<mark_weaver>what micro version? "2.0.x" what is the x?
<slucxx>$8 = "2.0.11"
<slucxx>string-copy just have on argument
<mark_weaver>slucxx: so now I'm confused. You asked why (string-copy ss "hello") doesn't overflow the string in 'ss'. but that should have raised an error about the second argument. Does it not raise an error for you?
<mark_weaver>I get: ERROR: In procedure string-copy: ERROR: Wrong type (expecting exact integer): "hello"
<slucxx>It's my fault, my really code is that,
<slucxx>(let ((ss (make-string 1))) (set! ss (string-copy "hello")))
<mark_weaver>ah, okay.
<mark_weaver>that works because 'ss' is actually a pointer to a string object.
<slucxx>i think everything is point within scheme
<mark_weaver>semantically, yes, that's true.
<slucxx>ss just keep the point of new string
<mark_weaver>actually, we represent some immutable types as immediates.
<mark_weaver>e.g. small integers and characters.
<mark_weaver>but yes, you can think of everything as a pointer, and you won't go wrong.
<mark_weaver>yes, exactly, you were just setting 'ss' to point to the new string and discarding the other one.
<slucxx>mark_weaver: okay
<mark_weaver>okay, I'm off to spend some time with my family. happy hacking!
<slucxx>mark_weaver: thank you
<slucxx>from the heart
<slucxx>good night everyone
***cluck` is now known as cluck