IRC channel logs

2023-02-02.log

back to list of logs

<apteryx>hi! I'm seeing a strange error from a Guile scripts; it seems to fail at running "(setlocale 6 "en_US.utf8)"; full context: https://paste.debian.net/1269461/
<apteryx>I'm wondering if the nested 'begin' could cause problems?
<apteryx>I think the error may have been misleading
<mfiano>apteryx: what about doing what the manual suggests; ‘(setlocale LC_ALL "") ?
<mfiano>Just wondering if that is the argument it is unhappy about.
<apteryx>that code runs fine, I think the error was somewhere else, not sure what happened there
<mfiano>Yeah strange. Error messages could shed some more context.
<cow_2001>how do you remember all the eq? eqv? equal? semantics?
<old>eqv is for equivalent
<old>they are equivalent for an human, for example (eqv? "foo" "foo")
<old>but in the machine they may not be the same object
<old>eq? well typically a pointer comparaison, i.e. does these objects point to the same memory
<cow_2001>comparing pointers is cheap, so it's short. how about this mnemonic?
<old>sure!
<old>The shorter the faster
<old>that could be it
<cow_2001>and equal? goes all the way deep inside
<old>yea it's like true equality
<cow_2001>in ,describe eq? i see that (let ((n (+ 2 3))) (eq? n n)) is unspecified, so it ruins everything
<cow_2001>"eqv? should be used for numbers and characters" but i don't see why the same n here shouldn't just return a #t
<old>I'm pretty sure that (lambda (x) (eq? x x)) if #t no matter what
<old>s/if/is
<old>I'm no Scheme guru, perhaps someone know why
<ArneBab>cow_2001: I just use equal? except if there’s a very special reason not to.
<cow_2001>ArneBab: me too! but i still want to know ~_~
<cow_2001>i'm doing 1.20 in sicp. an exercise in patience.
<ArneBab>cow_2001: ok :-) — eq? is "is" in other languages. It’s the most primitive. I don’t care about eqv? :-)
<ArneBab>so my personal use cases are only equal? and eq?
<old>typically eq? if want to check if it's the same reference
<old>Which is great for symbol that are literal since they are interned
<old>that allows for quick search in an associcatio map/list with a simple pointer comparison instead of strcmp for example
<old>for number, always `=' when possible. All other cases, equal?
<cow_2001>okay, simple enough
<ArneBab>I really loved the little Schemer, by the way.
<cow_2001>it is amazing
<ArneBab>I regularly had lights of understanding going up in my mind while reading.
<ArneBab>It’s awesome what they managed to create there.
<mfiano>cow_2001: the length of the symbol's name
<mfiano>the shorter, the more concrete
<mfiano>eq? on a number doesn't make a lot of sense, because it is more or less checking that the pointer is same.
<mfiano>and they are of arbitrary size, so can't be true
<mfiano>A lot of places in the standard check the identity though
<mfiano>like with eqv?
<mfiano>Like a `case` form iirc
<mfiano>In r7 at least. It's the only one I read so far :x
<mfiano>old, cow_2001 The reason why eq? cannot be used reliably on numbers is because numbers larger than a machine word minus size of tag are big nums and consed on the spot, rather than immediate values.
<cow_2001>woah.
<cow_2001>i wish ,described said something about that
<cow_2001>err
<cow_2001>,describe
<cow_2001>wait, did it?
<cow_2001>maybe i should make a patch?
<old>sure. But gotta to agree that (lambda (x) (eq? x x)) is #t
<cow_2001>okay, for applicative order... err, no, for normal order evaluation there are 16 remainder calls!
<old>even if x is big number
<cow_2001>it's the same consed bignum (i don't really know how bignum work, but i understand they are compound data)
<cow_2001>but same value bignums created in different places would have different areas in memory
<cow_2001>so the example in ,describe is wrong? the let there is exactly your lambda, old
<mfiano>big nums are just stored on the heap instead of the stack or directly in a register
<mfiano>a bignum is a pointer to system memory. a non bignum is literal bits in program code.
<ArneBab>cow_2001: describe sounds like numbers are a special case. Maybe because NaN cannot be equal to NaN
<mfiano>more or less, depending on implementation
<mfiano>That too.
<mfiano>You should never compare floats without an absolute and/or relative tolerance though...
<ArneBab>but (eq? nan nan) ⇒ #t
<mfiano>Good point though, even though I would never think to use exact comparison for a float
<cow_2001>ArneBab: oh my gourd. trying to create NaN i see that nan is a procedure that creates nans. there is no such thing as a variable named NaN.
<ArneBab>(I just tried)
<mfiano>huh
<ArneBab>ah …
<ArneBab>I was careless …
<cow_2001>and this is much more detailed than i had thought
<old>cow_2001: NaN has many representation bit wise
<ArneBab>((λ(x) (eq? x x)) (nan)) ⇒ #t
<mfiano>Yeah of course, it's the same pointer
<mfiano>Try with 2 (nan)'s
<old>(/ 0.0 0.0) gives Nan
<old>(eq? (/ 0.0 0.0) (nan)) => #f
<old>(nan? (/ 0.0 0.0)) => #t
<lloda>there's a literal nan, +nan.0, which should always be the same bits
<ArneBab>(map (λ(comp)((λ(x) (comp x x)) (nan))) (list eq? eqv? equal? =)) ⇒ (#t #t #t #f)
<lloda>but indeed if you get it through an op it could be anything
<old>cow_2001: Believe me. Scheme actually got it right. Just look at the mess they've made in Javascript
<old>e.g. == vs ===
<old>a.k.a how to shoot yourself in the foot with a single character
<old>the minus one bug equivalent in C
<ArneBab>I have a fun commit in our company git repo: "mind the truthers!" — fixes an if(x) problem, because x could be "".
<cow_2001>old: it's detailed because details matter
<ArneBab>Until I hit that, I did not understand how well Scheme hat hit the right approach: only #f is #f.
<old>ArneBab: Rust actually got it right too. True is true false if false
<old>WAnt to test for string empty? Call the dang function
<old>and it must return a boolean
<cow_2001>if only rustlang wasn't curl | sh type of hack job
<old>true
<old>lot's of .unwrap
<cow_2001>python is one big pile of unwraps and it's doing fine
<cow_2001>(and scheme)
<cow_2001>i've forwarded something here and it's not yet here. strange
<old>I meant that in Rust you need to unwrap every value wrapped in a Maybe type
<old>Real nice for production I guess, real pain for quick prototyping and developing
<cow_2001>that's why you use .unwrap()
<old>yes
<cow_2001>then you grep all your unwraps and replace with something neater
<cow_2001>no, it didn't work. maybe i'm somehow banned or quieted?
<cow_2001>how do i check BrownJenkin's status in this channel?
<old>what's that
<cow_2001>i've sent a thing using matrix
<old>Eeh I don't know what's BrownJenkin
<old>an user?
<cow_2001>my matrix user
<old>sneek: seen BrownJenkin
<sneek>Sorry, haven't seem 'em.
<cow_2001>very strange. i can see all messages but cannot write any.
<old>I do see it in the users list
<old>It's probably shadow banned?
<mfiano>matrix does that often actually. sometimes i've seen a delay of 20 minutes. I stopped using it, and I pay less attention to [m] suffices if they conversation doesn't make sense, because I never know if I'm talking in real time or not
<mfiano>I mean they got they R in IRC wrong :)
<mfiano>got the*
<cow_2001>okay, here's the thing i wanted to send https://0x0.st/oCsn.jpg
<old>nice fish
<old>good reprenstation of what bash is
<cow_2001>mfiano: what did they think R is?
<cow_2001>old: a sunfish.
<mfiano>Who knows. But it stands for real-time, which the matrix bridge frequently is far from.
<cow_2001>alas ~_~
<cow_2001>why can't we have a good discord competitor ~_~
<cow_2001>wait, i've went too far away from guile and scheme
<mfiano>k4m3n whoever you are, you revived r/guile with 2 days left to spare for being 1 year dead.
<cow_2001>i've just had a bad idea. what if we had a (cut f <2> <3> <3> <1>) standing for (lambda (a b c) (f b c c a))?
<ArneBab>old: but Rust is not from 1970, so it did not yet prove that it sticks to the right solution :-)
<nckx>I'd certainly have made use of that bad idea in the past.
<lilyp>cow_2001: That's not part of SRFI 26, but it is equivalent to C++'s std::bind IIRC
<cow_2001>i hereby proclaim cutr and cuter as the weirdo <1> equivalent to cut and cute
<cow_2001>now i just need to write the damned macros ~_~
<cow_2001>and i don't even know how to really write macros
<mfiano>I found the r7 spec pretty nice for someone that never understood scheme style macros.
<mfiano>as flatwhatson put it, it just gets right to the point. easy to read and find stuff.
<mfiano>I think end of ch4 and beginning of ch5 explain macros and how to use them
<mfiano>been a week or so but i think those chapters are correct
<lloda>i haven't used bind in c++ since c++ got lambdas, and c++ lambdas are a lot clunkier than scheme's
<wklew>cow_2001: as long as we give up complaining about haskell syntax forever :p
<lechner>Hi, what's a reasonably simple way to obtain an HTML page title from a URL, please
<lilyp>lechner: search for <title> and parse it as sxml or use htmlprag
<ekaitz>lechner: regex? :)
<mirai>lechner: what are you trying to parse
<mirai>RFC specs?
<mirai>you can get the titles via bibtex, much better than regex'ing or sxml'ing HTML output
<mirai>by "get the titles", you can use something that will read bibtex or plain regex
<manumanumanu>cow_2001: I wrote this some years ago: https://hg.sr.ht/~bjoli/megacut
<manumanumanu>it is almost hygienic even.
<manumanumanu>Considering all the other macros I wrote back then it is amazing I got it to work. I even managed to write a decently efficient tree walker.
<lechner>mirai / where may i find guile-bibtex, please?
<mirai>I don't know if it exists (try guix search) but I'm sure you'd find https://datatracker.ietf.org/doc/rfc5737/bibtex/ much easier to extract the title from rather than its html counterpart
<lechner>mirai / yes, thank you for the suggestion! it just took me some time to figure that out myself :)
<rekado>lechner: for arbitrary HTML (if no other structured format is available) I’d use htmlprag and sxpath
<cow_2001>manumanumanu: everyone's on sourcehut? what about codeberg? i will look at the code and see if i get anything
<cow_2001>oh and you are a Linus, too!
<cow_2001>just noticed it is an hg repo, not git