freenode/#lisp - IRC Chatlog
Search
9:33:55
ikrabbe
I often try to write macros that call functions from their arguments: (defmacro mac (x) `(,x y))
9:35:10
ikrabbe
I can guard this call with fboundp of course (defmacro mac (x) `(if (fboundp ',x) (,x y))
9:36:23
ikrabbe
) but this only works for defun'ed objects, not for (labels ((x () )))) (does it work for (lambdas?))
9:37:54
no-defun-allowed
In the case of the MAC you wrote, the implementation will usually signal a WARNING at compile-time if the function is not bound, so you shouldn't have to worry about it.
9:38:57
no-defun-allowed
Though I wonder if there is something you can do with the CLtL2 environment introspection extension which many implementations provide (given that FBOUNDP does not take an environment argument, but you can get an environment with that information from a macro).
9:44:38
no-defun-allowed
ikrabbe: This implementation of MAC generates (redundant) warnings for unbound function names: https://plaster.tymoon.eu/view/2381
9:47:15
no-defun-allowed
That might only work on SBCL, but I found a trivial-cltl2 system on Quicklisp which should be more portable.
9:47:19
edgar-rft
A macro-lambda-list has an optional &environment parameter to look-up lexically bound functtions (flet, labels, etc.) but I have no clue how that works.
9:59:04
ikrabbe
no-defun-allowed: What I actually miss is a branch for cond, when I parse such arguments: (say "Good morning" (user 10))
9:59:56
ikrabbe
(defmacro say (&rest x) (mapcar (lambda (o) (typecase o (sequence (if t `(,(car o) ,@(cdr o))) (print o)) (t (print o)))) x))
10:01:05
ikrabbe
This is an error of course, as "Good morning" is a sequence also. I need a cond statement if (car o) is callable.
10:02:33
no-defun-allowed
Would you not want to test for the LIST type instead of SEQUENCE? And then I suppose (equal `(,(car o) ,@(cdr o)) o)
10:08:21
ikrabbe
no-defun-allowed: list or sequence, the problem of the sequence can easily be overcome by deciding on strings before. My problem is still the missing condition.
10:15:42
no-defun-allowed
Are you trying to print at macroexpansion time? Local functions will not exist at compile time and cannot be called.
10:36:10
ikrabbe
no, that was just too short, but I begin to understand, that I should define all callable functions for a macro expansion.
10:37:00
edgar-rft
I just was going to say "why does that thing to be a macro at all when a function will do the same".
10:44:27
ikrabbe
it does not need to be a macro. But then I need to call it as (say '("Good morning" (user 10)))
10:55:14
edgar-rft
It was not meant as a negative critic, I only wanted to know if there is some reason that I can't see from the example code. Writing macros needs to care a lot more about corner cases than writing functions, as you already found out youself :-)
10:57:47
no-defun-allowed
Does it? You could write (defun say (&rest r) (mapcar #'print r)) to get (say "Good morning" (user 10)) to print "Good morning" then the result of (user 10)
11:07:04
ikrabbe
no-defun-allowed: actually print is just the test application. Depending on the situation I want (user 10) to be evaluated later. For the terminal it might be (print (user 10)), or in clim it could be (write-string (user 10)) or (present (user 10) 'username)
11:08:23
ikrabbe
when i do (defun say (&rest r)) the evaluation of (user 10) will likely be a string, but I lost the information that it is a user
11:30:12
mmontone
Hello. Does anyone know if there's a way of getting the list of packages loaded by a particular ASDF system?
11:31:28
ikrabbe
lotuseater: I could do many things, but I want to decide what to do, when I know anything about the output medium. When I write such a say statement in a html context, I might want to link to a user account... and user is just a simple example of what is possible
11:37:54
Xach
mmontone: i don't believe there is any easy way. a system may cause other systems to load that define more and more packages that aren't directly loaded by that system.
11:38:20
Xach
mmontone: but you could look at interceding at certain points and comparing snapshots of (list-all-packages)
11:40:27
mmontone
I thought perhaps there was some trick, like parsing ASDF system and files, or perhaps from swank information, but I don't think there's something. And I need it to be fast and lightweight, I don't want to trigger some file system processing or something like that, because I'm trying to implement an on-line documentation tool.
11:42:01
Xach
mmontone: i don't think there is any way aside from loading the asdf system and looking at the state of the package system.
11:43:46
mmontone
Yes..probably not possible. I was just asking just in case. Thanks for the input Xach.
11:47:01
Xach
mmontone: another option is to look at the xref data for packages, and see if the source file is in a particular known system
11:58:06
mmontone
https://drive.google.com/file/d/17uGr0B1OVc6nX9f73p3Hhqn5jRSx6bY8/view?usp=sharing
12:01:05
mmontone
Occurred to me when I was using slime completion to see what some package provided, and I couldn't see much from there, docstrings, etc. So I thought that was not the right way, there could be better ...
13:14:33
drl
Why is this no longer working: (let ((target-email-address (concatenate 'string "to=" (getf record :e-mail))))
13:14:34
drl
(uiop:run-program "/home/l/Downloads/thunderbird/thunderbird" (list "-compose" target-email-address)))
13:15:44
drl
This works (from the command line): [~]% Downloads/thunderbird/thunderbird "-compose" "to=FortChicag@aol.com"
13:19:37
Bike
i think you might mean (uiop:run-program (list "/home..." "-compose" target-email-address))?
13:21:17
Bike
i don't know what to tell you. as far as i can tell this is how run-program has worked since 2017
13:21:35
Bike
https://common-lisp.net/project/asdf/uiop.html#UIOP_002fRUN_002dPROGRAM here is the documentation's description
14:13:36
rumbler31_
hey all, trying out ql:bundle-systems. I am trying to make a reproducible build of a local-project, and I've managed to make a bundle of its dependencies (but I can't seem to include the local-project itself). If I were to load the bundle.lisp, how do I then load the local-project without loading quicklisp?
14:32:28
rumbler31_
seems like a local-projects folder is being created in the bundle but the original local-project filde ris not being moved in. I'll see if I can debug that
14:43:09
rumbler31_
I swear I did this exact same thing a moment ago but now its working for some reason
14:51:46
rumbler31_
copying all of local projects seems excessive but I suppose the answer to that would be "patches welcome"
14:58:51
Xach
rumbler31_: there isn't an automatic way, but you could copy your local project into the bundle's local-projects directory.
15:03:41
rumbler31_
its been a while. used it at my last company to check in a source tree that my coworkers could rebuild with make. its been years so I'm standing that up again from whole cloth
15:36:19
rumbler31_
does prefixing an as-of-yet-uninterned-sybol with #: prevent it from being interned?
15:45:18
jcowan
rumbler31_: So if foo already exists, the new #:foo is distinct from it in the sense of eql.
15:56:07
rumbler31_
I'm kinda dumb right now. why is it a good practice to use that prefix when specifying, say, quicklisp packages to load. And also, whats the preferred library for doing things like copying files? UIOP?
15:58:16
jdz
But it basically boils down to interning arbitrary symbols in whatever package the user currently happens to be.
16:06:46
beach
rumbler31_: More important than the random interning is that you send a clear signal to the person reading your code, that the package of the symbol is of no importance, and the only important thing is the name.
16:09:04
remexre
If I want to define the same :around on a whole group of generic functions, what's the right way to do this? is there some mop trick, or am I better off just using macros
16:11:57
beach
A method can be present on at most one generic function, so you have to make distinct methods.
16:13:14
remexre
if I adjust my wording to, "define an :around on any generic function (that opts into it, perhaps with a special method combination?)" is that more possible?
16:14:35
beach
I mean, you can certainly do all this programmatically. After all, the DEFMETHOD form expands to some calls to functions.
16:41:31
cage_
hi! why (cl-ppcre:split "\\n" (format nil "~2%s")): => ("" "" "s") but (cl-ppcre:split "\\n" (format nil "~2%")); => nil ?
16:44:56
jackdaniel
I once had a problem and I thought: I know, I will use regexps! Then I had two problems.
16:45:22
rumbler31_
its not clear to me what the argument to asdf:system-weakly-depends-on should be. I've tried '#:project-name and "project-name"
17:04:41
cage_
this is tangential, but i'd love if there was a discourse (web forum) instance about lisp, maybe hosted on common-lisp.net
17:21:46
fiddlerwoaroof
cage_: if you don't actually need regular expressions, there's split-sequence
17:30:44
fiddlerwoaroof
It's interesting how all these split functions implement the keyword argument that limits the number of items in the return value differently
17:36:32
fiddlerwoaroof
the count counts the number of times the string is split, so the number of resulting elements is count+1
18:07:24
remexre
is the point of boole that it might be calling out to like, a hardware blitter or something?
18:09:39
cage_
rumbler31_, my very personal beliefs make me stay away from proprietary/surveillance platform, of course i hav eno problem if other find this platform useful but just they are not for me
18:10:52
Nilby
remexre: Yes, but it can have other uses. For exmaple CLX uses the bool-* symbols as the drawing function in the graphics context.
18:15:32
Nilby
One can do other interesting things with boole, like database bitmap index operations.
18:28:47
rumbler31_
anyone know why ensure-directories-exist would fail, when all but the last folder in the given path is created?
18:40:42
mfiano
All but the last directory being created implies you are supplying a file pathname, so fix it with make-pathname or wrap it in the above
18:42:41
rumbler31_
(ensure-directories-exist "/home/user/quicklisp/local-projects/project/project-bundle/local-projects/project/" :verbose t)
18:57:21
rumbler31_
i'm spending an inordinant amount of time getting common lisp to make a new directory and copy 3 files into it. sorry to gripe
19:04:40
Nilby
One simple way to see what's actually happening, is to trace the systems calls using something like strace on linux or truss on bsd, so you can see what actual file system call might be failing.
19:41:09
rumbler31_
Nilby: So there's a lot of lstatting of the right paths, I don't understand enough to find the syscalls for copying files
19:52:46
Josh_2
just found a program breaking bug that was because I missed the : on my :initarg definition
20:36:29
rumbler31_
it goes all the way down to two with-open-file macros and just copies the a buffer at a time into the output stream, and if