freenode/#lisp - IRC Chatlog
Search
5:52:53
no-defun-allowed
(The end goal is to make my regular expression compiler more modular, and allow the client to generate specialised scanning code, based on CPU features and/or any specific knowledge of the text to match.)
6:00:15
fiddlerwoaroof
no-defun-allowed: if you need complex regular expressions to benchmark, this code here generates some amazing regular expressions: https://gitlab.common-lisp.net/rfc2822/rfc2822/blob/master/regex.lisp#L118
6:01:44
fiddlerwoaroof
I tried printing one out once to see why CL-PPCRE was taking so long to match something like "foo" <foo@bar.com>
6:06:16
beach
fiddlerwoaroof: In Cleavir, we get some of the benefits of using standard objects in macros, in that the compiler manipulates CSTs rather than expressions, and after macro expansion, it reconstructs a CST from the original one and the expression returned by the macro expander.
6:08:59
fiddlerwoaroof
It's occasionally seemed to me that the distinction between a compiler and a macroexpander is sort of arbitrary
6:11:24
fiddlerwoaroof
They're both programs that take a datastructure that represents a program in one way and turn it into a datastructure that represents the same program in a different way.
6:12:58
Nilby
If I'm remembering correctly I think agnostic-lizard uses a technique something like that, wrapping interim macro expansion in objects.
6:13:11
fiddlerwoaroof
One interest I've had is trying to pull some of the traditional compiler stuff into the macroexpansion phase, because that phase has always seemed easier to think about (to me)
6:14:43
beach
Yeah, that's a good idea, provided that errors and warnings can still be meaningful to the programmer.
6:14:46
fiddlerwoaroof
Nilby: I believe I remember seeing something like that in the presentation on that tool
6:48:17
no-defun-allowed
I use the derivative method, so I can do intersections on regular expressions.
6:49:25
fiddlerwoaroof
Basically, I've had this sort of problem before: I have N regex-action pairs (think awk-style programs, or HTTP routing) and I want to pick an action doing as little work matching as possible
6:50:14
fiddlerwoaroof
I think the derivative-style matching would work for this, now that I think about it
6:51:01
no-defun-allowed
After testing, I can only conclude that submatching here is painfully broken.
6:58:09
contrapunctus
Would you folks recommend using Clostrum for sandboxing Lisp programs? Or is there another way? It seems like a complicated problem.
6:58:51
Shinmera
the only way is to either restrict the programs to the point of being useless, or running another process.
7:00:44
fiddlerwoaroof
In theory, you could spawn another process and use the cgroups APIs to sandbox it
7:05:23
contrapunctus
fiddlerwoaroof: to be specific, I don't want the program to (unless the user permits them) make any network requests or access the filesystem outside of its private storage. (There's also some resource limiting.)
7:05:38
beach
contrapunctus: To get the benefits of Clostrum, you need to be able to evaluate expressions "relative to" a Clostrum environment, so you need a specific evaluator.
7:06:10
beach
contrapunctus: We have such an evaluator (obviously), but things are not set up for general use. Currently, it is used only in SICL bootstrapping.
7:07:15
beach
contrapunctus: The existing evaluator turns a source file into a CST (using Eclector), and then the CST into an AST (using Cleavir) and then it uses the AST evaluator of SICL that does the job.
7:08:10
beach
One day, I may turn these tools into something generally usable, but I don't have the time to do that now. Perhaps someone else would be interested in such a project.
7:28:54
no-defun-allowed
As with most of the engine, I have no idea what I did exactly, but submatching appears to work properly now.
7:32:39
contrapunctus
beach: I see. I feel quite sad when I think of how, on one hand, it's desirable to have programs in e.g. documents, and yet the state of sandboxing and resource limiting leaves much to be desired.
7:35:08
beach
contrapunctus: I understand. I wish someone would take on the project I suggested. What you would like to see is something many people seem to want.
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