freenode/#lisp - IRC Chatlog
Search
10:21:23
jmercouris
is there something like WITH-PACKAGE where you can use a specific package to wrap a body?
10:22:08
jmercouris
I'm imagining a way that you could have like (with-pacakge :some-package (xyz "a")) instead of having to do (some-package:xyz "a")
10:23:10
jmercouris
could you make a macro using IN-PACKAGE? how could you detect the current package? or would you need to supply that to this theoretical macro?
10:24:38
jmercouris
fascinating so you could keep a reference to that and easily make a with-package macro
10:29:07
LdBeth
jmercouris: the funny thing is if you use a macro other than in-package the compiler would not see that
10:33:06
jmercouris
maybe one does have to use in-package, perhaps in-package does something special
10:38:58
LdBeth
If the file is directly loaded (setf package) is evaluated, if the file is loaded as compiled fasl it won’t
10:42:11
LdBeth
Although CLHS has specified this, I still think this behavior could be a source of confusion.
12:01:42
no-defun-allowed
i can't be held accountable (certainly not on #lisp) for your death either
13:46:58
ck_
trafaret1: for example, you can get a list by running (loop for sym being the external-symbols in :zsort collect sym)
13:49:39
ck_
there's also do-symbols, do-external-symbols, and do-all-symbols. Let's see if I remember the bot command
14:27:38
pjb
minion: memo for jmercouris: You need a reader macro, you cannot do it with a macro (because then you won't need what symbols were qualified). You cannot use #. because you need the input stream; when loading or compiling a file, *standard-input* is not set to the source stream!
14:31:33
pjb
minion: memo for jmercouris: https://pastebin.com/qJTUxwYc (note: !?{}[] as (dispatching) reader macros are reserved for the user, so don't use them in code published in quicklisp)..
15:17:22
Josh_2
I made a (with-..) macro that uses variables that are part of the hunchentoots package (*session* and *request*) do I need to gensym or something with this type of macro?
15:18:23
Bike
you use gensyms when you want a binding that doesn't interfere with any bindings the user might have.
17:16:25
pjb
Josh_2: I would say yes, I'd use something like (verifying-session …) or (ensured-session …)
20:01:18
krwq
is there some way to use uiop in such a way that you run infinietely running process (i.e. 'yes') and keep on reading the output. so i.e. (with-running-program ("yes" std-out) ())
20:01:51
krwq
I meant this inside the macro (loop for line = (read-line std-out) do (something line))
20:05:20
krwq
actually seeing uiop:launch, will play around, if someone has some example please let me know :)
20:08:51
aeth
krwq: yeah, launch-program is usually what you want, not run-program. Although there might be a better portability library to do the same thing.
20:10:17
krwq
aeth: so far I mostly used tiny wrapper on top of run-program since I've only run very short running commands and needed short output but now wanted to run something indefinitely and stream data
20:12:35
aeth
I use launch-program extensively in my very incomplete chess GUI to talk to a chess engine (i.e. chess AI) using the UCI protocol... Very messy code, though. https://gitlab.com/mbabich/cl-chess/blob/33b412cdd5b74c5c10b0799f10553cf6979abfc8/uci.lisp
20:15:14
aeth
Well, you probably won't get much from the code. Too disorganized, and the UIOP stuff is all over the place. The imports tell you what you need, though. launch-program, process-alive-p, process-info-input, process-info-output, terminate-process, wait-process, and process-info
20:18:04
aeth
The API for launch-program is full of boilerplate. There might be a library with similar functionality that's better there, or you might have to write a few helper functions/macros, maybe 30-60 lines or so.
20:18:57
krwq
aeth: I think I only need two options: either all string or all stream so will just have a func for string case and macro for stream
20:19:57
aeth
You'd duplicate some of the work of the library, but you could make that one code path by using a with-output-to-string stream
20:37:50
krwq
aeth: code is here: https://pastebin.com/QiKumC52 - so very thin wrapper on top of launch-program