freenode/lisp - IRC Chatlog
Search
13:08:15
jackdaniel
you have a special reader macro which switches you to sh syntax (and vice versa)
13:10:19
dim
I think a scsh comparable tooling already exists in CL, along with asdf/uiop facilities, by Fare again, right?
13:11:03
r13l
ooh, i hadn’t found SHELISP or CLESH. not a huge fan of shell syntax (i like that INFERIOR-LISP & scsh use s-expressions to represent commands), but still — really cool!
13:20:02
r13l
oh, no worries! thanks for the link. the big problem i had just using INFERIOR-SHELL is that — for some reason — programs it launches don’t get killed when their parent is killed, so e.g. typing C-c kills my lisp process but not the long-running command _it’s_ running (which is weird, because i’d expect them to all be in the same process group). which sent me down the rabbit hole …
13:23:43
r13l
yes, but e.g. a shell script does the right thing here. i haven’t (yet) read the source of e.g. zsh to see, but i imagine that it installs a SIGINT/SIGTERM handler which signals each child process, then terminates (so the children would only be orphaned if that handler isn’t run)
13:23:46
jackdaniel
you may also keep child processes in your collection and on sigint send them the same thing before exitting
13:25:09
r13l
yeah, i’m doing that now. i use UIOP:LAUNCH-PROGRAM instead of UIOP:RUN-PROGRAM, and install a signal handler (thanks to your advice yesterday) which kills each running process. i guard the list of running children with SB-SYS:WITHOUT-INTERRUPTS
13:25:53
jackdaniel
I've looked at UIOP:*-PROGRAM source code a few times and each time I was horrified
13:25:54
r13l
as you can imagine, my simple little script has gotten a bit unwieldy, hence my desire to find or write something which abstracts away some of the messy details *grin*
13:27:31
jackdaniel
Xach: I sometimes use external-program (which is also a simple wrapper around implementation native run-program)
13:27:49
jackdaniel
UIOP puts some abstraction on /everything/, including streams and files, even if implementation handles them better than UIOP
13:28:01
r13l
it’s actually a dirt-simple backup script: sets up some environment variables, runs borg to backup ~, runs notmuch dump | borg to backup my email tags, then runs borg backup twice. i’ve spent _way_ more time lispifying it than i should have, but … it’s fun *grin*
13:28:45
Xach
I have some build stuff that has to run git in a lot of different ways and it is really nice to be able to do it with lisp functions and macros instead of shell scripts.
13:29:35
Xach
And sometimes I feel like people want to bind to libraries to work like that, but I have had good success and have been very happy with run-program to get started. And much of the time it's more than enough for ever.
13:30:31
Xach
i had a system that processed thousands of images per day with imagemagick and i just spawned "convert" - no need to mess with binding to libmagick or anything else.
14:56:35
shrdlu68
"Quick test: if you create a new namespace and import another file within that namespace, do its contents end up in that namespace?"
15:04:04
dlowe
and packages aren't hierarchical in CL, so importing another file "within" that namespace doesn't make any sense
15:21:58
pjb
shrdlu68: if your file contains (cl:defun cl-user::foo (cl-user::x) (cl:+ cl-user::x 42)) and assuming no foul play with the *readtable*, then you can set the *package* to any package, loading the file will always read the same sexps!
15:22:40
pjb
shrdlu68: Similarly, as soon as the file contains a toplevel in-package form, it controls the package in which the following unqualified symbols are interned.
15:23:26
pjb
dlowe: usually, people write (in-package "BAR"). But if FOO::IN-PACKAGE is not CL:IN-PACKAGE, (in-package "BAR") can have different effects.
15:49:16
slightlycyborg
Hi. I have x predicate calls. What is the best way to sum up the number of predicates evaluated as true?
15:53:44
dlowe
I was trying to think of a way that didn't involve a temp list, but I didn't think of anything without macrology
15:55:44
loke
slightlycyborg: If every comparison uses the _same_ pred, you want to do: (count-if #'pred LIST-OF-VALUES)
15:57:16
slightlycyborg
Ya, the #'identity raised an interupt in my mind and I saw that pattern. I am not using the same pred for this instance though.
15:58:31
dlowe
If every comparison uses the same value and different preds, (count-if (lambda (p) (funcall p value)) LIST-OF-PREDICATES)
15:59:05
dlowe
(defmacro prog-count-if (&body forms) (let ((counter-sym (gensym "COUNTER"))) `(let ((,counter-sym 0)) ,@(mapcar (lambda (f) `(when ,form (incf ,counter-sym))) forms) ,counter-sym)))
16:01:36
dlowe
(tagbody 5 (defvar count 0) 10 (if (not (pred x)) (go 30)) 20 (incf count) 30 (format t "I am so cool. count=~a~%" count))
16:02:18
Xach
slightlycyborg: this steady drip-drip-drip of new info is excellent for stretching out the discussion and exploration of solutions!
18:29:52
fiddlerwoaroof
(length (flatten (mapcar (lambda (f v) (if (funcall f v) (1) ())) functions values)))
18:37:41
_death
jackdaniel: heh.. at first I was puzzled.. TRON operator? then I recalled TRON/TROFF...
20:53:30
aeth
LdBeth: If what you said was valid then it would constantly be setting a to 1 and then a to 2 every iteration of the loop. It doesn't seem to be valid in SBCL, it says "duplicated variable". verisimilitude has the answer.
20:53:44
verisimilitude
In any case, you should be using the integer stepping clauses for this, instead.
20:54:51
aeth
(loop :repeat 5 :for a := 1 :then (1+ a) :do (format t "~A~%" a)) is equivalent to (loop :repeat 5 :for a :from 1 :do (format t "~A~%" a))
20:55:11
aeth
The advantage of the second form is that you can add a terminating condition right in it instead of writing your own elsewhere.
20:56:03
LdBeth
well, Emacs' cl-loop don't signal an error on duplicated variable and just complains "unused variable a" when byte-compiled though
20:56:10
aeth
You can also count 0-based and by steps greater than 2. (loop :for a :from 0 :below 10 :by 2 :do (format t "~A~%" a))
20:57:39
aeth
LdBeth: The way I would have interpreted it if it was valid would be to have a set to 1 and then incremented by 1, so both a's would be used, sort of like (let* ((a 1) (a (1+ a))) a)
21:23:04
fiddlerwoaroof
it has most of the features of CL's generic functions, but adds &context arguments and a couple additional kinds of specializers
21:23:34
fiddlerwoaroof
the &context arguments let you dispatch based on things like the currently active mode, etc.
0:43:31
slightlycyborg
I am trying to get asdf to load a system that I placed in ~/common-lisp. I load quicklisp on sbcl boot. I am getting "component <system_name> not found" after (asdf:load-system "<system_name>")
0:46:31
slightlycyborg
I think I found the error. I named my file <system>.asdf instead of <system>.asd