IRC channel logs

2021-11-27.log

back to list of logs

<lilyp>yeah, I guess it was pre-srfi and guile does adhere to standards where possible
<drakonis>i want to write a library later
<drakonis>after i'm no longer swamped with work
***sneek_ is now known as sneek
<bud>hello i am trying to follow a SICP video thing. I thought guile was scheme? but i get error when i do (first `hello)
<bud> https://0x0.st/-7g-.png
<RhodiumToad>first is from srfi-1
<samplet>Guile doesn’t have ‘first’ by default (it uses the traditional/outdated ‘car’ instead). You can import ‘first’ by writing ‘(use-modules (srfi srfi-1))’. Also, I think you might have meant ‘(first '(hello))’.
<bud>thanks samplet!
<RhodiumToad>or ,use (srfi srfi-1) in the repl, saves a few keys
<bud> https://archive.org/details/ucberkeley_webcast_l28HAzKy0N8 <- this is the video, bt.
<bud>hmm
<RhodiumToad>are (first) etc. included in the base definitions of r6rs or r7rs? I haven't looked but I assumed not
<samplet>bud: Guile is great (that’s why we’re all here). However, if they mention which specific Scheme they are using, you might have an easier time following the lectures by just using the same one.
<bud>samplet, yeah. I am not sure, they just said scheme. and it is as i understand following SICP.
<bud> https://teachyourselfcs.com/#programming
<samplet>I think SICP uses MIT Scheme. Racket also has a SICP mode, too.
<samplet>MIT Scheme has ‘first’ in the default environment.
<bud>ok, i just picked guile because it was installed.
<KE0VVT>I wish it were possible to write portable Scheme code, so you could write programs in Guile programs but also compile them with Chicken.
<bud>aha, video is using UCB Scheme
<bud> https://inst.eecs.berkeley.edu//~scheme/
<samplet>KE0VVT: If you stick closely to the standard and are careful, it can work (I’ve never done it, but I’ve seen a handful of libraries that do).
<daviid>fwiw https://github.com/zv/SICP-guile
<bud>daviid: yeah i saw that, will try to figure this out.
<bud>i wonder if these first, last butfirst, bf functions aren't custom to the lecture..
<bud> https://github.com/fgalassi/cs61a-sp11 !
<bud> https://people.eecs.berkeley.edu/~bh/61a-pages/first-day-handout.pdf <- this is the handout for the lecuture.
<bud>at the very last page it describes these "procedures" (first, last, butfirst)
<bud>i still can't figure out if they are "custom" or built in to scheme?
<bud>i managed to install stklos, which is the REPL (scheme?) they use, but got same errors (almost) as with guile..
<samplet>bud: Here’s a file that defines them: https://inst.eecs.berkeley.edu/~scheme/source/src/ucb/bscheme/simply.scm
<RhodiumToad>as far as I can tell they are not part of r7rs-small, don't know if they are included in any other scheme spec
<daviid>RhodiumToad: first in sicp isnt the first of srfi-1, (first 'hello) => h ...
<RhodiumToad>oh
<bud>samplet thanks!
<RhodiumToad>well that's just silly then
<daviid>bud: no matter what scheme you use, you'll need to import (use or load) a 'sicp module... i recommend you download and use the version of berkley
<daviid>it is not just stklos, it has the module(s) you need(I think, didn't try but would rather 'trist' theinstructor ...)
<bud>daviid: thanks
<daviid>since your a re learning, avoid any 'headackes, just do what is recommended by the university/instructor
<daviid>bud: guile is wonderful, you'll be able to use it after that course of course ... now isnt rthe right time, imo
<daviid>*trust the instructor
<bud>yeah, thanks, you guys saved me some time.
<daviid>RhodiumToad: all additional procedures are described/defined in the course itself ... and remember, 1986 ... still the best cs cours ever ... here is the FIRST def: PROCEDURES TO TAKE APART WORDS AND SENTENCES:FIRST returns the first character of a word, or the first word of a sentence and so on ...
<daviid>*and so on [i added this:), as in it continues with other defs:)
***bandali is now known as mab
<janneke>Starting now: Emacs Conf - see https://emacsconf.org/2021
<dadinn>hi all
<RhodiumToad>evenin'
<dadinn>i am trying to understand how dynamic-wind works, and whether it's matches what I would like to use it for
<dadinn>i have this code: (dynamic-wind (const #t) (lambda () (error "FUCK YOU ASSHOLE!")) (lambda () (display "NO PROBLEMO!")))
<RhodiumToad>yes, and?
<dadinn>I get an error with the unsatisfid T-800 message, but it never seems to learn how to say no problemo
<RhodiumToad>how are you running it?
<dadinn>I was expecting that this would work like a finally block in Java :/
<RhodiumToad>yes, but how are you running it?
<dadinn>I mean the last lambda should be executed
<dadinn>I am running it in Geiser
<RhodiumToad>when you run it interactively in guile (I don't know about Geiser), the REPL gives you the exception prompt when the error is raised before unwinding the stack, so you're still inside the block at that point
<RhodiumToad>if you then control-D out of the recursive prompt, it then outputs the "NO PROBLEMO"
<dadinn>hmm... when I pressed C-q it still didn't print
<dadinn>I mean C-c q
<dadinn>or whatever C-c C-q
<dadinn>ah sorry it did!
<dadinn>except the newlines
<RhodiumToad>your display doesn't output any newline
<dadinn>I do have newlines before and after the display
<dadinn> https://imgur.com/a/wd70Vy3
<dadinn>ah no sorry I am confusing myself...
<RhodiumToad>it's probably clearer if you put your dynamic-wind inside a function and run it in a (catch) or (with-exception-handler) to take the REPL's exception handler out of the picture
<RhodiumToad>e.g.
<RhodiumToad> https://dpaste.org/GAwv
<RhodiumToad>that's having done a (define (foo) ...) with your code
<dadinn>got it!
<RhodiumToad>notice that in this example the stack is unwound before calling the catch handler, so the "NO PROBLEMO!" is printed first
<RhodiumToad>the more complex case is when you escape from the block using a continuation, that can get a bit twisty
<dadinn>so the error propagates upwards after the stack is unwound by default?
<RhodiumToad>that's dependent on how the error is being caught.
<RhodiumToad>are you using guile2 or guile3?
<dadinn>guile-3.0
<dadinn>I know it came out recently
<RhodiumToad>ok. the difference between the two is that 3 unifies the various error mechanisms into one, so they're the same underneath
<RhodiumToad>if you look up with-exception-handler in the docs, it tells you about how the unwinding works
<dadinn>so with-exception-handler is only available in guile3?
<RhodiumToad>it's in guile2 in the (rnrs exceptions) module, but it doesn't work to catch errors
<RhodiumToad>in guile2, errors are implemented with catch/throw, and r6rs exceptions are separately implemented with catch/throw
<RhodiumToad>so catch can catch r6rs exceptions but with-exception-handler can't catch errors or throws
<ArneBab>KE0VVT: please tell me how wisp works for you!
<RhodiumToad>whereas in guile3, catch/throw uses structured exceptions, and both forms work to catch the other
<dadinn>i am surprised to see that exception handling works that it catches one type/key, and then it has a handler for that. If I want a handler to handle different types of errors separately, do I have to catch everything (with #t), and then do a case on the key?
<dadinn>In Java you have that "pattern-matching" on type for the exception block
<RhodiumToad>which form of catch are you looking at?
<RhodiumToad>in general, I believe the idea is that you want to catch errors by way of a specific exception type, where a composite structured exception may be of many types at once
<KE0VVT>ArneBab: How do I get to the Wisp REPL?