IRC channel logs


back to list of logs

<dsmith-work>So 32bit little-endian
<KarlJoad>How can I turn this `(system* '("ls" "-l" "-a"))` into `(system* "ls" "-l" "-a")`? I know what I want to do, but do not know the terms to use to search for this task.
<KarlJoad>That is a general example I need for a script I am writing.
<gabber>KarlJoad: if i understand you correctly, you can achieve that with (apply)
<gabber>i.e. `(apply system* '("ls" "-l" "-a"))`
<daviid>gabber: if you actually need to see or write the expression, then here is how `(system* ,@'("ls" "-l" "-a")) => (system* "ls" "-l" "-a")
<daviid>gabber: sorry, i meant to write to KarlJoad :)
<gabber>daviid: np
<KarlJoad>daviid: That will be helpful for the printing I do too, but that is just debug printing. What gabber said was what I wanted for that example. Now I need to turn (system* "cmd" "arg" '("maybe" "things" "here")) into (system* "cmd" "arg" "maybe" "things" "here").
<KarlJoad>I know those "things" will be present, I just do not know the format yet.
<KarlJoad>I guess the other way to handle this would be, how do I flatten something like (system* "cmd" "arg1" '("arg2" "maybe-arg3")) into just (system* "cmd" "arg1" "arg2" "maybe-arg3")?
<daviid>you call flatten
<daviid>which is not in gule but a few libs have it ..
<daviid>KarlJoad: here is one version (inspired by another guiler, thanked in the commit but not in the source, saying this because last time they complained when i actually póinted to this version ...) -
<old>dsmith-work: I don't remember. I've never program in emacs lisp
<old>but I did remember trying a snippet that someone (maybe you?) paste here for stepping function in emacs
<old>the experience was good
<daviid>KarlJoad: feel free to just snarf the flatten code of course ... it's free s/w ...
<KarlJoad>daviid: I thought flatten was what I wanted, I just didn't find any reference to it.
<toideng>can anyone recommend some sort of explanation on how macros are resolved?..
<toideng>r7rs isn't quite clear :-(
<haugh>Why does this type-error?
<haugh>(start-stack 'foo (stack-id (make-stack #t)))
<cwebber>did one-argument errors break?
<cwebber>(error "foo")
<cwebber>scheme@(guile-user)> (error "foo")
<cwebber>;;; <stdin>:1414:0: warning: possibly wrong number of arguments to `error'
<cwebber>ice-9/boot-9.scm:1685:16: In procedure raise-exception:
<cwebber>Wrong number of arguments to #<procedure error (who message . irritants)>
<cwebber>Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
<cwebber>I thought I remembered older versions of guile supporting just (error "something")
<cwebber>certainly much of Goblins' code uses that
<haugh>works on 3.0.5
<cwebber>I'm on 3.0.8 here
<cwebber>it may be good hygiene to always have additional information
<cwebber>I'm just surprised
<haugh>manual page is 6.13.9
<cwebber> -- Scheme Procedure: error msg arg ...
<cwebber> Raise an error with key ‘misc-error’ and a message constructed by
<cwebber> displaying MSG and writing ARG ....
<cwebber>normally I interpret ... as "0 or more"
<toideng>is there any kind of rule for deciding if a certain form is a macro call or a procedure call?..
<haugh>toideng, maybe you want macroexpand
<toideng>haugh, that thing is interesting, but i was thinking more of evaluation order
<toideng>for example, i define a "macro extractor": ```(define (get s) (module-ref (current-module) s))```
<toideng>if i then enter something like ```((get 'define) a 2)```, i gen an unbound variable error (`a` is unbound)
<toideng>but something like ```(define b (get 'define)) (b a 2)``` works just fine?..
<haugh>It looks like you're trying to treat macros as first class objects. May God have mercy upon your soul
<toideng>...are they not suited to be treated as such?..
<haugh>I'm not qualified to answer that question
<toideng>i got this question when i was trying to figure out at which point does a symbol become a value
<toideng>i had heard an explanation that the first element in the list is evaluated first, and then everything else is evaluated or not depending on the obtained result
<toideng>but, apparently, that is not what is going on; that is also not what r7rs spec says
<haugh>The Guile Manual describes first-class macros as "a bit difficult" which I translate into the English: "it is easier to cast a shadow from space"
<toideng>the manual says that about getting the macro as an object, and immediately shows, how to do that
<haugh>Very astute but as you can clearly see, simply slapping these objects into calls doesn't do quite what you want, does it?
<toideng>no, it does not
<toideng>i think i get it now, thank you
<toideng>(it probably has to do something with pattern-matching)
<haugh>So I'm just a noob speculating here but my current impression is that this kind of functionality depends on the type of syntax transformer. I don't even grok syntax-case yet, so I'll save hackery for after that
<toideng>i now believe that the mechanism probably works as follows (give or take): upon evaluation, the form is pattern-matched against the set of all known syntax transformers, and if it does not match any, all elements are evaluated in an unspecified order and then the form is treated as a procedure call
<toideng>this would explain why ```((get 'define) a 2)``` doesn't work
<cwebber>must have been something I imported
<cwebber>(error "foo") works fine in 3.0.8 in general
<dsmith-work>Tuesday Greetings, Guilers
<mwette>Have a great day!
<lloda>shouldn't (string->date (date->string (current-date) "~4") "~4") work?
<lloda>i guess guile only has a partial implementation
<haugh>lloda, template-string and format-string are different specifications in the standard, no?
<haugh>cwebber, maybe there's some conflict with SRFI-23?
<haugh>oh nvm that's the builtin
<lloda>haugh: hmm i see :-/
<dgcampea>how does match work for bytevectors? I'm doing `(match #vu8(0 1 2 3) (#vu8(0 x ...) x))' but I keep getting `In procedure bytevector-u8-set!: Wrong type argument in position 3: x'