IRC channel logs
2025-01-18.log
back to list of logs
<lechner>mwette / maybe i misspoke. it got better. i have another error elsewhere, i think. it's hard to debug with multiple levels of shared libraries <mwette>OK. I wonder if we should add a list of ptr-references to the cdata type, then when a pointer is generated or a pointer struct field is updated it is added to the list. <lechner>mwette / does the let rule apply to receive, as well? <mwette>I don't know, but guess yes, since I believe the variables are bound in as lambda parameters. <stevelitt>I'd like to get some opinions. In what situations do you all use the REPL instead of writing the program in an editor and running guile on it? <ieure>stevelitt, It's not really an either-or, it's a both. <ieure>Write in the editor, send it to the REPL and donk around with it a bit, edit to fix whatever stuff isn't working, repeat. <dsmith>I think most people user geiser. Almost as nice as hacking on elisp <dsmith>Don't be shy about trying paredit. I avoided it for years, but it's really worth it. <rlb>ACTION was not very clever for not learning paredit sooner... <stevelitt>lechner, ldsmith, I don't use emacs because I find it too difficult both physically and mentally. <ray1729>What is the best way to work around an exception thrown by http-head? The root cause is a remote site returning an ETag header with unbalanced quotes, so the exception is thrown when parsing the response headers. <ray1729>The rest of the response is useful, ideally the web client would just return the raw value for this header rather than a parsed value. <sneek>I've been aware for 14 minutes and 5 seconds <sneek>This system has been up 15 minutes <mwette>ray1729: I'd try to catch the exception, which gives you the continuation, and then call the continuation a bogus result. You might have to dig into the code to get the context right. <ray1729>mwette: I was hoping I'd be able to do something like that, but not sure how to. Can you point me at an example? <ray1729>My naive attempt throws a &non-continuable error, and if I add #:unwind? #t it unwinds further than I want. <mwette>I'm guessing the error is in code in web/http.scm somewhere. <ray1729>Yeah, it's coming from the parse-qstring function, the error is #<&compound-exception components: (#<&error> #<&irritants irritants: (qstring "\"3e01-62b7563ad28b9;62ab2bbd2a9cb")> #<&exception-with-kind-and-args kind: bad-header-component args: (qstring "\"3e01-62b7563ad28b9;62ab2bbd2a9cb")>)> <mwette>and using handler (lambda (k key . args) (k "bogus")) didn't work I guess <mwette>hang on -- that's not the signauture i've used <ray1729>I was trying with with-exception-handler, which expects a function of just one argument (the exception object) <mwette>got it. w/ catch there is a second handler that gets the continuation <mwette>I looked in http.scm and the c code for string exceptions and don't see where non-continuable comes from. <ray1729>Oh, that came from my naive attempt at handling the exception: <mwette>How about (with-exception-handler (lambda (k) (k "bogus")) (lambda () ...)) <stevelitt>What's the coolest thing any of you have done with Guile? <ray1729>mwette: that triggers the error "Wrong type to apply", I think because the k in that case is an exception object, not a procedure. <mwette>I was just checking that. I'm reading now ... <ray1729>If I try (with-exception-handler (lambda (e) 'bogus) (lambda () ...) #:unwind? #t) then I do get back the value 'bogus, but the result I want is lost. <ray1729>I think that if (web http) called raise-continuable instead of throw, then I could catch the exception and continue with the 'bogus value. <mwette>Sorry. I don't understand what's going on. I tried tracking down how throw does that but I can't find it. non-continuable makes the code faster. <mwette>ray1729: will probably fail but what about (catch #t (lambda () (http-head ...)) (lambda (key . args) #t) (lambda (k) (k "bogus"))) <ray1729>mwette: that returns #t (the value from the exception handler) <danlitt>Hi, I have a question about guile debugging. I'm used to Ruby's binding.break, where you set a breakpoint by editing the code (add a line where you want to break) and any time the interpreter hits that line you get a REPL where you can inspect the local variables and things. If I am reading the manual correctly, the corresponding guile concept is a trap? I can see the procedure add-trap-at-procedure-call! but it is not behaving how <danlitt>ct. In particular when I type ,locals in the REPL I can't see the function arguments (I'm calling the proc (fac n) as (fac 4) so I expect to see n=4). Should I? I can add code if it helps explain. <mwette>Sometimes you get more visiblity if you first compile your code with `guild compile -O0 file.scm'. Overall, the visibility via debugger is not the best. <danlitt>mwette: thank you for your link - your set-local! is exactly what I'm looking for, I think. I don't really understand the stack very well, so I think I will try to roll something on my own, as an exercise. <dodoyada>anybody got pointers on how to use prepared statements + transactions with guile-sqlite? I'm wanting to do something like insert into a user table and insert into a password table in the same transaction but with guile-sqlite I so far only know how to do a single statement as a prepared statement, or a transaction as multiple statements but without the prepared arguments <Arsen>how does it work in each case? <dodoyada> (let ((stmt (sqlite:sqlite-prepare db sql))) <dodoyada> ;; `pair?` used here is practically the same as `empty?` so here we're just seeing if there are args. <dodoyada> (apply sqlite:sqlite-bind-arguments stmt args)) <dodoyada> (let ((result (sqlite:sqlite-map identity stmt))) <dodoyada> result)))` here's what I have for running a single statement as a prepared statement <dodoyada>every prepared statement implicitly begins a transaction when it's prepared, and ends when it's finalized <dodoyada>guile-sqlite also has (sqlite:sqlite-exec db sql)) which can execute multiple statements but doesn't accept arguments so I use it for DDL where there is not input from external sources <Arsen>does that also hapepn if you execute a BEGIN statement first? <dodoyada>lol I was about to cite the same source to say you would need to for each statement, I'll re-read it <Arsen>yes, you must finalize all statements, but not for each execution <Arsen>ISTM that guile-sqlite3 overloads the term finalize from sqlite though <Arsen>but yes I feel like if you ran BEGIN first you could issue multiple statements and they'd be one transaction - I'd try that first <Arsen>(easiest way to check AFAIK is to try to ROLLBACK and see what happens) <dodoyada>so I should sqlite-prepare, sqlite-bind-arguments, and sqlite-map each statement in order but finalize in order after everything has been sqlite-map-ped? <Arsen>from a quick reading --- sorry, I haven't tried it :( --- it seems so to me <dodoyada>"not a transaction started by BEGIN" yeah this sounds like the ticket <dodoyada>(define debug-connection (sqlite:sqlite-open "debug.db")) <dodoyada>(query-no-finalize debug-connection "BEGIN;") <dodoyada>(query-no-finalize debug-connection "INSERT INTO users (email, name) values (\"fadasdfsdf@ljsdf.com\", \"fadasdf\")") <dodoyada>"Throw to key `sqlite-error' with args `(#f 5 "database is locked")'." on the INSERT line, working through this atm <dodoyada>I'm under the impression that I get "database is locked" if I try to start a new transaction without finalizing a previous transaction on the same connection <dodoyada> (query db "INSERT INTO users (email, name) values (\"fadasdfsdf@ljsdf.com\", \"fadasdf\")") <dodoyada>"A statement finishes when its last cursor closes", guessing this happend if I sqlite-map