IRC channel logs


back to list of logs

<chrislck>i.e. how to access a binary buffer from C and convert to SCM
<RhodiumToad>you need to do it all from C?
<RhodiumToad>and you want a list of numbers, not characters?
<RhodiumToad>simplest method is probably to just cons it up backwards from the end
<chrislck>hmm not super elegant but ok
<chrislck>scm_from_utf8_string is not right because of these '\0' obviously
<chrislck>hoping for similarly concise
<chrislck>alternatively how to convert/case char* into #vu8
<RhodiumToad>converting a char* to #vu8 should be simple
<RhodiumToad>where's the char* coming from?
<RhodiumToad>do you want a bytevector that copies the bytes, or that aliases them?
<RhodiumToad>looks like scm_pointer_to_bytevector is of interest
<RhodiumToad>you could easily do an extra copy if you want a copy
<chrislck>ah looks like it
<chrislck>now need to look into scm_gc_protect and stuff
<RhodiumToad>well making a copy is probably the easiest way to avoid gc complications
<ArneBab_>rlb: lokke looks like the perfect tool to get a colleague to Guile — thank you!
<rlb>ArneBab_: hah, you're welcome, though it's definitely early days.
<apteryx>how do I match a pair? (match pair ((a . b) ...)) or (match pair ((a b) ...)) ?
<apteryx>the earlier (thanks, REPL :-))
<rlb>When working on lokke, remembered that if you want to make a dialect for guile that has it's own #! interpreter, you may have to generate binaries to be portable, i.e. solaris and darwin derivatives don't allow the #! target to be another #! script.
<RhodiumToad>what systems do allow that?
<RhodiumToad>freebsd certainly does not, for example
<amirouche>leoprikler: + re fash better name
<leoprikler>apteryx: for pure pairs you probably want (match pair ((a . (? (negate pair?) b)) ...))
<leoprikler>not sure if that works, but you can try
***apteryx is now known as Guest98549
***apteryx_ is now known as apteryx
<RhodiumToad>or ((a . (and (not (? pair?)) b))
<RhodiumToad>missing ) there somewhere
<manumanumanu>rlb: if you want a C extension with fectors, I would suggest c-rrb. I think it is permissive, and is probably the fastest implementation of rrb-vectors around. They will be faster than fector, but also have fast concatenation, splitting and in-the-middle insertion.
<manumanumanu>the cost of rrb-trees over, say, fector by andy, is a small check: (if (split-or-concatenated? fector) (sliightly-more-expensive-lookup fector index) (regular-fector-lookup fector index))
<manumanumanu>whereas splitting and concatenating is o(1)-ish instead of o(n).
<manumanumanu>the other known implementation of them are arximboldi's immer c++ library which comes with basic guile bindings. That one has regular fectors (called vector) and rrb-trees called flex_vector. He reports a worst-case slowdown of 2x, but only after _excessive_ splitting and concatenating.
<rekado>I’ve been playing with guile-rsvg and noticed that an error is thrown when closing an rsvg handle immediately after writing a non-ASCII character to it.
<rekado>the rsvg API expects you to close the handle to indicate that no more writing will occur.
<rekado>there is no such problem when using rsvg-handle-new–from-file (which does not require writing to and closing of the handle)
<ArneBab_>rlb: that’s a good point …
<ArneBab_>RhodiumToad: there are systems that re-target binaries to #!-scripts
<ArneBab_>RhodiumToad: for example check `head $(which guix)`
<chrislck>RhodiumToad: thx a lot for your help!
<pinoaffe>hi folks, a while ago I asked about the guile repl, didn't really get a clear answer, so I'm going to ask again: does the guile repl support on-the-fly modification of state (followed by resuming execution) when an exception is raised, along the lines of the workflow described in ? I read the article, and figured if guile support this, it could make my repl-interaction
<pinoaffe>quite a bit easier
<pinoaffe>I read the repl command documentation bit didn't really understand how those commands relate to eachother
<dsmith>pinoaffe: Guile (and Scheme) doen't have restartable exceptions like CL does.
<dsmith>pinoaffe: Also, doesn't save the in-memory image to be reloaded later. So you can't type in definitions at the repl, save, type in, save ...
<dsmith>Instead, you use geiser/emacs and type in a new def in a file, and then send that def to a running Guile. Run, Edit, Repeat.
<dsmith>Very similar workflow, but you have the code in a file.
<manumanumanu>pinoaffe: you could write restarts using continuations if you want to
<manumanumanu>but other than that, the answer is no :)
<pinoaffe>dsmith: thanks, thats what ive been doing
<pinoaffe>manumanumanu: thanks to you too
<manumanumanu>pinoaffe: whoa. I just stumbled on something fun, that is tangential to what you are doing. (ice-9 local-eval). Trying to do something like what you are asking for is going to be fun in the bad sense!
<manumanumanu>but you could write something where an error gives the error handler access to the lexical environment of the error, which means you can set! to your hearts desire
<manumanumanu>as long as things are not inlined, of course
<manumanumanu>(define meh 6) (define e (the-environment)) (local-eval '(set! meh 11)) (display meh) => displays 11.
<manumanumanu>and it works badly with the dynamic environment, so parameters are not the same.
<manumanumanu>hihi. I haven't had this much fun since the city burnt down.
<rlb>RhodiumToad: sounds like #! targets can be interpreters in the minux and linux worlds (and can "recurse". Guessing the solaris/darwin claim extends to the broader *bsd world too:
<rlb>manumanumanu: thanks - I'll put that on the investigation list, though clojure vectors explicitly don't support concatenation or insertion if that makes a difference.
<rlb>(but even if so, might be interesting to have variants that do -- have to think about it)
<manumanumanu>rlb: as I said, they are a superset of clojure's persistennnt vectors. The difference is that the rrb-trees relax the balance requirement, which makes you use a lookup table whenever you have done a concat/split. if that LUT is not present, use the regular pvector lookup :)
<rlb>Oh, I just meant that clojure has no operations that will allow vector concat or insertion atm.
<manumanumanu>so it is really (if (LUT? fector) (more-expensive-lookup fector index) (fast-lookup fector index))
<manumanumanu>you have to manually copy it
<rlb>Hmm, though I suppose maybe concat or into might be optimized to take advantage in some cases, *if* that were deemed to be acceptable wrt the actual documented behaviors.
<manumanumanu>o(log n) is pretty much o(1) in these cases
<manumanumanu>anyway. good night :)
<rlb>I suppose perhaps concat shouldn't actually...
<RhodiumToad>rlb: so I wonder what happens on linux if a file's #! points to itself
*rlb guesses that linux has something like the symlink count limit at least...
*rlb guessed right :)
<rlb>$ ./foo
<rlb>bash: ./foo: ./foo: bad interpreter: Too many levels of symbolic links
<rlb>after an echo -e "#!./foo\nsomething\n" > foo
<dsmith>I wonder how many is "too many"?
<RhodiumToad>probably about 32
*rlb guesses a power of 2
<rlb>Apparently "_POSIX_SYMLOOP_MAX is 8" (at least).
<dsmith>"As currently implemented on Linux, the maximum number of symbolic links that will be followed while resolving a pathname is 40."
<RhodiumToad>that's a strange choice
<RhodiumToad>anyway, #! interpreters may have a different limit
<dsmith>Right. I was looking there the error message mentioned symlinks.
<dsmith>there because ...
<RhodiumToad>can't imagine why they would choose 40, though