freenode/lisp - IRC Chatlog
Search
7:46:05
pyc
Ah! I see one does not add a newline and the other one does while printing the string but they both seem to return the same string.
7:48:58
ludston
pyc: Easy to test the difference with (let ((s (make-new-output-stream))) (write-string "blah" s) (get-output-stream-string s))
11:44:12
pyc
Is there any best practice guidelines for write-line vs. format? Is format to be avoided when write-line would suffice?
11:45:37
pyc
I see all tutorials and PCL book use format even while printing simple strings. Makes me wonder why write-line is ignored. For simple strings, the code looks neater with write-line.
11:46:43
phoe
for me it's (format t "...~%") or (format t "~A~%" variable-string); possibly superfluous, but I never really felt the need to use write-line
11:47:30
pyc
phoe: thanks. that is what I wanted to know. for single characters, I guess you use write-char (still not write-line), am I right?
12:01:57
pyc
Xach: thanks! Incidentally, I was looking for write-line on the web and I came across your code. I agree I like (write-line line) to be cleaner than (format t "~A~%" line).
13:50:56
ralt
_death: are you still maintaining dbus? I've been playing with it again this week, and the main issue I have with it is the error reporting. For example, an invalid list of parameters returns an EOF error
13:53:35
ralt
Because the introspection is runtime but the classes and their slots are defined at compile time :/
15:28:19
_death
ralt: sure, I can review and accept patches.. not using it nowadays so there are no changes coming from me
15:38:43
_death
ralt: I guess one way to make a lispy interface would be to write something that generates stub code from an interface and dump it to a file.. then your code could depend on that stub (harnessing asdf) and the names it exports
17:49:54
rlp10
How do you append a subdirectory to the end of a pathname? I'm finding the number of different libraries a bit confusing, since what I want to do is pretty common I guess.
17:52:10
rlp10
phoe: Thank you, that's really helpful. I guess it's the other way round from what I was expecting, but that makes no odds. I don't know why I was struggling to find it so much. Anyway, I appreciate your quick response - thanks.
17:53:42
aeth
phoe: shouldn't it be uiop:merge-pathnames* to fix portability issues between implementations?
17:55:19
rlp10
aeth: So is that what I should be using? Quite a bit of my scripting deals with folders, files, their contents etc.
17:57:25
aeth
rlp10: uiop/filesystem and uiop/pathname and uiop/configuration (and maybe a few other parts of uiop) may be able to help with some of your problems, but I'm not very familiar with the nuances because I rarely work with complicated file-based operations. Iirc, ASDF mostly uses UIOP for this.
17:58:03
aeth
rlp10: e.g. (uiop:xdg-config-home) should get you the correct parent directory of where you should put your configurations.
17:58:30
aeth
Well, on Linux (XDG) and on Windows (whatever Windows uses). It treats macOS like a Unix, rather than using macOS's custom conventions, so it might not be fully idiomatic there depending on what you're doing.
17:58:42
rlp10
OK, I have to confess that I'm new, so I don't fully understand what uiop and asdf are. I'd probably better start by reading their websites.
18:00:37
aeth
rlp10: Packages in CL are namespaces for symbols. Quicklisp is the "package" manager, but since the name "package" was taken, it's really the "system" manager. Systems are ASDF systems, and they basically are the standard library format in CL. ASDF fills a similar role to e.g. make. ASDF uses UIOP as its utility library, which means UIOP can be useful if you're dealing with files.
18:02:45
aeth
UIOP or CL-FAD should give you what you need, but since most people already have UIOP installed (because it's used by ASDF), the latter is probably more popular.
18:04:18
aeth
UIOP does a *ton* of extra stuff, but it's mostly used for its file/path/etc. functionality.
18:13:32
aeth
It's usually polite to stay within subdirectories of uiop:xdg-config-home or uiop:xdg-cache-home or uiop:xdg-data-home if reading/writing. If only reading, then asdf:system-source-directory will get you the directory of a system (i.e. library). I guess you start from cl:user-homedir-pathname if you want to read/write e.g. ~/Documents
18:37:42
aeth
ralt: yes, and then you can write something like this: (apply #'path-from-dir (funcall lookup-function) (append (if org-name (list org-name)) (list app-name)))
18:38:57
aeth
ralt: that should get you "professional" looking usage of ~/.local/share/ (or whatever the #'xdg-data-home happens to be configured as) where it's ~/.local/share/your-organization/your-app/ or ~/.local/share/your-app/
18:42:15
aeth
(In that case, #'path-from-dir is in turn just a trivial wrapper over uiop:merge-pathnames*)
19:05:37
aeth
ralt: doing (uiop:xdg-data-home #P"foo" #P"bar") I get ~/.local/share/bar rather than ~/.local/share/foo/bar
19:08:26
aeth
ralt: You also need to reverse the order, since the optional part (the parent directory) comes first.
19:09:19
aeth
What I mean is, you want to input "bar" "foo" or "bar" NIL and get #P"foo/" #P"bar/" or #P"bar/"
19:13:13
ralt
#p"foo" is a pathname that represents a file, so when you try to use it and don't get it as part of a folder... that's expected
19:14:05
aeth
ralt: This is slightly improved: (apply lookup-function (append (if org-name (list (uiop:make-pathname* :directory `(:relative ,org-name))) nil) (list (uiop:make-pathname* :directory `(:relative ,app-name)))))
19:18:50
aeth
i.e. (funcall lookup-function (make-pathname* :directory `(:relative ,@(if org-name (list org-name) nil) ,app-name)))