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
20:40:49
krwq
aeth: I don't like thinking about names uiop used. They feel inconsistent - i.e. I usually group functions with similar functionality with prefix (i.e. process-*) besides I have found bugs in so many libraries already that I prefer to create wrappers so that I have stable APIs
20:41:51
aeth
There are probably lighter ways to rename a function. Maybe even just making the trivial wrapper functions inline.
20:42:15
krwq
aeth: while usually in lisp people prefer verb-something (i.e. kill-process rather than process-kill) I have gone with less english readable names but easier to discover
20:43:38
aeth
Common CL implementations basically never automatically inline unless you tell them to, afaik.
20:44:08
krwq
I don't care, when I do I will fix it - process execution is already way higher overhead than that
20:44:59
krwq
aeth: besides I've already started using builtin stuff after a way so many times :P (wasn't convinced to APIs at first but once I expanded my use cases I decided to just use original)
20:46:51
krwq
aeth: true but I have my own tiny standard library and I try to avoid putting stuff there which I'm not convinced will be useful yet
20:47:38
aeth
for renaming, maybe with one of those libraries that take a function lambda list and then `(progn (declaim (inline ,new-name)) (defun ,new-name ,old-lambda-list ...)) ; might get tricky with keyword/optional
20:50:54
krwq
basically playing with ADCs in C# on my Raspberry PI and wanted to plot the data in lisp from my main machine so will just run C# app by ssh and print the data out
20:51:35
krwq
would prefer use lisp all the way but need the ADC for work so got constrained by the language
20:56:52
krwq
Josh_2: that's what my plan was hence my question about streaming from process (technically could use sockets as well but didn't want to add too much logic in the process)
21:06:49
Josh_2
One of which has been sending data over sockets from java to cl backend, no problemos
21:06:50
aeth
The default encoder/decoder treats CL's NIL as JSON null, and one-way translates JSON's false to CL's NIL. https://common-lisp.net/project/cl-json/cl-json.html
21:07:42
aeth
That's a sign of a complete failure to understand that CL's NIL is used as false considerably more often than as a null-equivalent, and causes me to completely distrust the competency of the author
21:09:17
aeth
You can probably override that and do something like NIL <-> false, and :null <-> null, but I'm not sure I trust code written by someone who shows such a lack of understanding of the language that the author doesn't even understand a language's "false".
21:09:58
Josh_2
I suppose because I have always decided the data that is sent it hasn't been an issue
21:10:44
aeth
But look at that table (which is a pretty useful table). The defaults are not round-trippable.
21:11:15
aeth
So going CL->JSON->CL could give you different data than you sent. e.g. sending #\C will give you "C"
21:12:55
aeth
At that point you might as well not directly support characters/symbols and require that the user convert them imo. CL isn't an auto-coerce language, there would be a (+ 1 "foo") probablem even if + was overloaded to also mean concatenate 'string