IRC channel logs
2025-04-25.log
back to list of logs
<cow_2001>what is the difference between a chapter and a section and a subsection and a subsubsection? can't i just use nested chapters? <cow_2001>you cannot do something like this in skribilo (chapter :title [outer chapter] (chapter :title [first inner chapter] [body of first inner]) [body of outer chapter] (chapter :title [second inner chapter] [body of second inner chapter])) <lechner>Hi, is there a predicate to test whether something is an S-expression, or does that not make any sense? <old>lechner: anything that can be read by the reader is an S-expression <old>"this is an s-expression" <old>So I would say that having a predicate for an S-expression could be something like so: <old>(define (s-expr? string) (and (false-if-exception (call-with-input-string string read)) #t) <old>(s-expr? "foo") => #t <dsmith>old, Nice! I would not have thought of that. <old>morenonatural: if your FFI accept pointers, you can: string->pointer <morenonatural>old, thank you ... didn't think such would be under the "void pointers and byte access" section (I just quickly scheemed through it) <old>morenonatural: nothing special. I use it as a convention for "real" implementation <old>could had been: primitive-strcmp <lechner>Hi, is 'eval' the inverse of 'quote'? <old>lechner: to quote is to not eval <lechner>so (eval (quote x) (interaction-environment)) is always x, right? <old>Stricly speaking, I don't think you can say that quote is the inverse of eval <old>if `x' is defined in the interactive environment you will get that value <old>if you want to get the symbol x you would do: (eval (quote (quote x)) ...) <lechner>actually, i meant that x is an arbitrary S-expression <old>assume the following: (define s-exp '(+ 1 1)) <old>(eval 's-exp (interaction-environment)) <old>you get: (list + 1 1) <old>(eval s-exp (interaction-environment)) <old>by applying eval to `s-exp' you are evaluation `s-exp' itself first <old>so you end up evaluating '(+ 1 1) which is 2 <old>but if you eval 's-exp, you will get wathever is in that symbol <lechner>old / i am not though, am i? (eval (quote x) (interaction-environment)) from above just means that, for your sexp: '(+ 1 1) is (list + 1 1) which true, isn't it? <old>if X is an s-expr like above, you get that s-expr back if you quote its evaluation <old>I think I understand your point now <old>f-1 being the inverse of f <lechner>old / thank you for your help today! <lechner>Hi, what's the relationship between 'read' and 'eval', please? <ieure>lechner, Lisp-generic answer: `read' takes text and turns it into lists; `eval' evaluates (executes) lists containing Lisp code. <old>lechner: read: string -> s-exp; eval: s-exp -> s-exp <old>actually read is taking a port, but get the gist. It creates s-exp from a sequence of token <lechner>okay, thanks! is (quasiquote ,(read X)) the same as (quote X) ? <lechner>actually, (quasiquote ,(call-with-input-string X read)) <morenonatural>what's The Guile Way to do those monadic `null-or-int` thingies? just like this? 👉🏾 (and (null? maybe-int) (something maybe-int)) <mwette>morenonatural: (integer? maybe-int) <mwette>not sure what detail you're after <morenonatural>in this ☝🏾 example, `get-default-value' is not called if `maybe-some-value' is not `nil' <rlb>lechner: note that read only reads one value, so it won't look at anything after that e.g. (call-with-input-string "1 '") <old>morenonatural: There's nothing in Guile or Scheme for that. But you can roll your own like you want <lechner>rlb / thanks! that's good to know. should it return a 'values' thingy? <rlb>No, it's explicitly intended to work that way -- if you want to read all the values in the input, you loop until you get (eof-object? x). <rlb>(or it crashes on a bad s-exp) <lechner>Hi, does the underscore _ have a special meaning in Guile, beyond common convention? <lechner>or asked differently, what does people do when they want to ignore two arguments in a lambda definition? Using _ twice yields duplicate identifier in argument list in form (_ _ arg seed) <ieure>lechner, I think it's mostly convention, though some macros may treat _ specially (thinking of `match' here). Not sure if this is a Guile convention, but it's idiomatic in Clojure to ignore any underscore prefixed argument, so (lambda (_foo _bar arg seed)) <rlb>...the underscores in clj and python may also signal the linter(s) <rlb>(eastwood, kondo, pylint, etc.) <dsmith>When defining a macro, the macro name in patterns is redundant and often is replaceed with _ <morenonatural>I have items with a "start", and I want to assign each item an "end" which would be the next item's "start" (last item has no "end")... any way of doing this ergonomically in guile? <ieure>morenonatural, Probably something like (map (lambda (pair) ...) (zip list (cdr list))) will get you most of the way there. <ieure>The lambda will end up with a list, where the car is an element from the list and the cadr is the next. <ieure>Note that this drops the final element, so you probably want (append (cdr list) '(#:end)) or something like that to even them back out. <old>lechner: I would recommend to always name things <old>even if not used, having a name help understand the code <old>the exceptions to this rule is: catch-all match pattern: (match ... (_ catch-all)) <old>good lord as I was writitng that last message, I saw a fox fetching one of my chicken and running with her into the forest <old>fortunatelly, I ran after them and I got the chicken back <dsmith>ACTION attempts to say something clever about Foxes with "Guile" and Chicken Scheme but mercifully gives up