IRC channel logs

2023-10-23.log

back to list of logs

<RhodiumToad>or just:
<RhodiumToad>(define foo (case-lambda ((one) ...actual body here...) ((two one) (foo one)))
<mirai>RhodiumToad: that wouldn't quite work with what's happening on the snippet no?
<RhodiumToad>(let (...) (define foo (case-lambda ...)) foo)
<RhodiumToad>ok, it's basically just shorthand for a letrec, but it should work
<RhodiumToad>could turn the whole thing into one letrec* I suppose, as in
<RhodiumToad>(letrec* ((fields* (if ...)) (func (case-lambda ((_ value) (func value)) ((value) ...real body here...)))) func)
<tohoyn>sneek: botsnack
<sneek>:)
<tohoyn>daviid: ping
<tohoyn>daviid: "autoreconf -ivf" does not work in g-golf version 0.8.0-rc-1 if g-golf is already installed in the system. See https://paste.debian.net/1295918/.
<tohoyn>daviid: sorry, it is "make" that does not work.
<sneek>tohoyn: wb :)
<apteryx>eh, srfi-64 is written in a Guile 3 agnostic way
<apteryx>and it doesn't make use of srfi-34 / 35 because ";; In 2.0.9, srfi-34 and srfi-35 are not well integrated with either Guile's native exceptions or R6RS exceptions."; is this still true 11 years later?
<daviid>tohoyn: hi, yes it's been a while acutally, not just rc-1, and i couldn't figure out exactly why (yet)- you(users) just have to uninstall before 'make'
<tohoyn>daviid: ok
<apteryx>what does and-map do? it appears undocumented
<apteryx>I guess it stops with #f the moment it encounters an item for which its predicate fails to match?
<apteryx>if so, how is it different from every?
<apteryx>err, 'every'
<RhodiumToad>every accepts multiple lists, otherwise they're the same afaict
<RhodiumToad>and-map probably only exists because a bunch of other boot-9 functions use it
<apteryx>I see; so in normal programs, it seems the documented 'every' is a better construct to use?
<RhodiumToad>probably.
<dsmith>There are things in Guile that pre-date the srfi's, but are slightly different. and-map might be one of those.
<dsmith>apteryx, ^^ I think that's the answer to a lot of the "Why are there 2 different ways to do this?"
<mirai>RhodiumToad: interesting, I don't typically see letrec being used
<mirai>I never quite understood why or when would you want to use it since it looks like you can achieve the same using a plain let?
<RhodiumToad>no, let and letrec differ in scopes
<RhodiumToad>(let ((a 1)) (let ((a (+ a 1))) a)) => 2, because the a in (+ a 1) is the outer a
<RhodiumToad>so
<mirai>ohhh
<RhodiumToad>(let ((f (const 1))) (let ((f (lambda (a) (if (> a 1) (* a (f (1- a))) 1)))) (f 3))) => 3, because the inner call to f calls (const 1)
<mirai>so with letrec it would be the inner a / the a that is being defined?
<RhodiumToad>but
<RhodiumToad>(let ((f (const 1))) (letrec ((f (lambda (a) (if (> a 1) (* a (f (1- a))) 1)))) (f 3))) => 6, because now the inner (f) is properly recursive
<mirai>doesn't seem to make sense if a is a plain variable but it would for recursive variables
<mirai>recursive procedures*
<mirai>right, makes sense
<RhodiumToad>letrec usually only makes sense for lambdas or other things with deferred evaluation because while the new bindings are in scope for all of the definitions, they do not yet contain values, so evaluating them before the definition is completed is an error
<mirai>thanks
<RhodiumToad>(not necessarily a thrown exception, the value might just be returned as #<unspecified> or whatever)
<RhodiumToad>letrec and letrec* differ in that while in both, all new bindings are in scope for all definitions, in letrec all definitions are evaluated before storing any value, whereas letrec* stores the value of each definition before processing the next
<RhodiumToad>so later definitions in a letrec* can evaluate immediately the earlier bindings, but not the reverse
<RhodiumToad>so local use of (define), as in (let ((a 1)) (define b (1+ a)) (define (c n) (+ n b)) (c 123)) is basically just another way to write a letrec*
<RhodiumToad>i.e. (let ((a 1)) (letrec* ((b (1+ a)) (c (lambda (n) (+ n b))) (c 123)))
<RhodiumToad>(ok, that example doesn't actually use recursion, but imagine using (define) to do local recursive functions instead)
<ekaitz>hi! this is the most obvious thing in human history but how can I make guile give me useful backtraces?
<RhodiumToad>are you getting the wrong-type error, or some other problem, or is it just that you're not seeing the info you expect to see?
<ekaitz>RhodiumToad: i just get lines that don't mean anything eval:...
<ekaitz>they are not part of my code
<ekaitz>so it's really hard to find where that happens
<RhodiumToad>example?
<ekaitz> http://paste.debian.net/1295963/
<apteryx>I can't use 'syntax-source' in a syntax-rules macro, can I[/
<apteryx>?
<civodul>hey wingo, would you have spare cycles to chime in on https://github.com/wingo/fibers/issues/89 ?
<sneek>Welcome back civodul, you have 1 message!
<sneek>civodul, phf says: Great!
<dsmith>sneek, botsnack
<sneek>:)