***christianabryant is now known as tomsitprocb
***sneek_ is now known as sneek
<civodul>wingo: 'syntax-local-binding' is future-proof, right? <wingo>what are you doing with it? :) <civodul>BTW, Racket has syntax properties, and i think we need to add a 'properties' slot too *tupi wonders if and when civodul sleeps, as he grabs more and more [hard] maintainer work! is he drinking asterix magic potion? <civodul>tupi: i'm effectively non-maintaining Guile these days... <tupi>wingo: hello! i am sure you don't sleep much either :), but i'd like to ping you about guile-gnome-platform, guile-clutter..., so that you take a little of your precious time to answer related emails ... [since you answered dt and dh emails, I am jalous :)] *dje42 is wondering if he's abusing out-of-range error <mark_weaver>dje42: what are you doing that might be considered an abuse of out-of-range error ? <aleix>hi, what would be the nicer (idiomatic) way to conditionally add an element to a list? i'm using something i don't really like: (if <cond> (set! l (append l l2))) <aleix>sorry, i don't get much sleep lately :-) <mark_weaver>well, ideally you would avoid mutation. also, it's inefficient to add elements to the end of a linked list. better to add to the front and then reverse at the end, or use a higher-order procedure to avoid that. *aleix has been dad for second time <mark_weaver>can you give me a larger view of what you're trying to do? <aleix>sure, it's really simple. it's for guile-redis. basically, i have a function that takes multiple arguments first one being the comamnd name: (make-command "COMMAND" arg1 arg2 args3 ...) <aleix>sometimes the arguments are optional <aleix>so i build a list and do: (apply make-command `("COMMAND" ,@args)) <aleix>the args have optional arguments might or might not be there <mark_weaver>you could also just do (apply make-command "COMMAND" args), btw <mark_weaver>procedures with optional arguments can be easily defined using: define* <mark_weaver>so where does the conditional appending of lists happen? <aleix>for example (define* (migrate host port ... #:optional (copy #f) (replace #f)) ...) <aleix>the migrate procedure uses this (apply make-command args) <aleix>then args is the list of arguments (host port ...) <aleix>and i need add COPY or REPLACE only if given <aleix>so, you could have a list (host port ... "COPY") or (host port ... "COPY" "REPLACE") or (host port ... "REPLACE") or simply (host port ...) <mark_weaver>well, I guess I would always pass those arguments, but pass #f if it's not given. <mark_weaver>so, where the "REPLACE" argument is expected, you could do (and <cond> "REPLACE") <mark_weaver>do you think symbols would make more sense here than strings? <mark_weaver>(I lack the context to know if that makes sense, but it seems strange to pass "COPY" or #f as a flag. <aleix>the migrate procedure is exposed as one of the commands of guile-redis <aleix>it might take this two optional arguments <aleix>internally, migrate uses (apply make-command "MIGRATE" args) <aleix>and i just build the args list with the arguments given to (migrate) <aleix>all the args are strings, btw, that's what make-command expects <aleix>then, i just want to add to my args list the "COPY" or "REPLACE" if the user has specified them when calling (migrate) <mark_weaver>well, one way is (append (if <cond> '("COPY") '()) ...) <mark_weaver>another way is (filter identity (list copy replace ...)) <mark_weaver>well, maybe that last one is not quite right for your code, but basically (filter identity <list>) removes all the #f elements. <aleix>and then reverse for the first case? <mark_weaver>if you find it more natural, you can use quasiquote as well: `(,@(if <cond> '("COPY") '()) ...) <aleix>ok, this looks much better than my (if <cond> (set! l (append ...)) <mark_weaver>in general, I recommend binding a new local variable rather than mutating an existing one. <mark_weaver>sometimes I'll use 'let*' to keep rebinding the same variable again and again, each time based on the previous one. <mark_weaver>e.g. (let* ((lst (if <cond> (cons 'foo lst) lst)) (lst ...) (lst ...)) ...) <aleix>ok, this last one was what i was looking for. i've always used let* to bind different vars but not same one <mark_weaver>though I still think that in this case, it's better to use a single call to 'append', or quasiquote. <aleix>with "what i was looking for" i meant something i could have known how to do :-) <aleix>yeah, happy hacking to you too! <wingo>aleix: congrats, re: second child! <youlysse`>So, is Skribilo being used to document in any Guile projects? It looks really nice, though I from the glance I took, thusfar I feel hard-pressed to find any exaple not located in it's doucmentation. <civodul>youlysse`: you found right, it's not very popular ;-) *youlysse` is intrested in rewriting the beginings of his introductory compsci text in it. :^) *youlysse` accidently removed his directory the other day, that held it -- and did make a backup of it thusfar. <youlysse`>dsmith-work: Yeah ... might as-well take it as an opportunity to try something new though. Too it's a general learning experience, to better prepare backing stuff up -- that I'm working on and care about. :^P <dsmith-work>youlysse`: Well, "do nothing" *is* a valid, though poor, backup strategy.