IRC channel logs

2021-12-01.log

back to list of logs

***daviid` is now known as daviid
***chris is now known as Guest1312
***Guest1312 is now known as chrislck
<excalamus>good morning, Guile
<excalamus>I'm working through the Little Schemer and in the section on eq?. It's answers say that eq? should only work for non-numeric atoms, yet eq? clearly works in the repl with numbers and lists. I find the same is true with mit-scheme, as well as Guile. I'm not sure what to make of this observation. Should I strive to only use eq? with non-numeric atoms?
<excalamus>s/it's/its
<lloda>eq? is kind of a low level concept
<tohoyn>eq? may work incorrectly for numbers
<lloda>it's meant for unique objects
<excalamus>okay, sounds like in scheme, the same thing applies as in (common) lisp, that eq/eq? should be used to compare symbols
<excalamus>(looking at land of lisp)
<lloda>not a clisper but i think it's the same
<tohoyn>eq? is fine for symbols and booleans
<ns12>excalamus: Refer to http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_idx_434
<excalamus>ns12, thanks
<ns12>Look at the examples. Where it says "unspecified", the implementation is free to return either #true or #false.
<excalamus>okay, that makes sense
<excalamus>I was thinking that it would return something like "unspecified", but "unspecified" just means undefine behavior
<excalamus>thank you, all!
<lloda>there's *unspecified* in guile which is a different thing
<excalamus>are there docs for that? Looking through the reference, the only thing I find is the example (let ((n (+ 2 3))) (eq? n n)) which returns #t. The reference says that's *unspecified*, but I think that's referring to the spec as in the example is comparing two numerics.
<chrislck>for guile there's https://www.gnu.org/software/guile/manual/html_node/Equality.html
<chrislck>does it really matter, for the little schemer, though>
<excalamus>not really, but trying to get a better understanding of the whole scheme ecosystem
<excalamus>figuring out how to look things up so I don't have to ask :)
<ns12>lloda: Could you give an example of the *unspecified* that you mentioned?
<ns12>Ah, I got it: (define x) (display x)
<ns12>x is #<unspecified>
<excalamus>cool, thanks
<excalamus>makes sense
<chrislck>#<unspecified> is the scheme equivalent of ∞
<ns12>Oh, and (display *unspecified*) prints #<unspecified> too. I wonder where this is documented.
<excalamus>in order to do my searches, I'm using emacs info reader. Sometimes I can find a node or menu item, but often need to search the whole manual. But really, most of the time, it feels like I don't find much. Is there another way to find this? I'm so used to the emacs documentation, I'm spoiled! I haven't had much luck with Geiser. Don't know if that's a config thing or if it simply runs into the same sorts of dead ends that info seems to
<excalamus>run into.
<excalamus>I'm looking through the R5RS, which I think came with my Guile install, and the Guile reference
<lloda>*unspecified* is used for two things
<lloda>first is as a hack for the lack of zero values
<lloda>so when something returns no values, it actually returns *unspecified*
<lloda>the other one is in some constructors like (make-typed-array 'f64 *unspecified* 10)
<ns12>But (values) is able to return zero values.
<lloda>as a way of saying that you don't care
<lloda>but nothing in Guile uses (values)
<lloda>i think the *unspecified* business dates from a time when Guile didn't have (values ...), but i'm not sure
<ns12>Maybe (values ...) is Scheme is not as convenient as it is in Common Lisp.
<lloda>i think it would be better if stuff like (if #f #f) actually returned zero values
<ns12>"Maybe (values ...) is Scheme is not as convenient as it is in Common Lisp" - I retract this statement, because it is not really true.
<tohoyn>just a thought: could we remove *unspecified* and use '() to mean an undefined value?
<ns12>tohoyn: How would you distinguish between *unspecified* and an empty list?
<tohoyn>ns12: maybe the idea is not so good
<lloda>i not sure there's any need to have a name for an undefined value
<lloda>it's something that doesn't exist
<tohoyn>lloda: BTW, in Theme-D you can't have procedure call with type <none> as an argument in an another procedure call
<tohoyn>lloda: and there is no way to assign an undefined value to a variable
<dsmith-work>ns12: An empty list is '()
<chrislck>IIRC *unspecified* had a 'here be dragons' somewhere in documentation
<dsmith-work>unspecifed is used in the repl to not display the value.
<lloda>tohoyn: interesting
<lloda>the use to mean 'i don't care what this is' is useful imo
<lloda>but returning something when you mean to return nothing, i think that's a defect
<tohoyn>lloda: yes, but as Scheme is not statically typed you can't prevent an expression returning nothing to be passes somewhere else
<tohoyn>s/passes/passed/
<tohoyn>I mean passing the value of expression returning nothing to another expression
<lloda>right, but that happens already with 1 value vs 2 values etc.
<tohoyn>true
<lilyp>excalamus: I think in your case, whatever you're constructing gets optimized by 1. the reader 2. guile's internal representation of numbers.
<lilyp>so even if you have two different 5s, they're actually the same
<lilyp>I'm not sure if that also holds for bignums, but it might
<lilyp>okay, it doesn't: (eq? (+ (expt 2 64) 1) (+ (expt 2 64) 1)) ;; => #f
<lilyp>in any case, eq? can only return #t or #f, never *unspecified*
<lilyp>(if *unspecified* #t #f) returns #t also
<stis>Tja guilers!