libera/commonlisp - IRC Chatlog
Search
7:27:34
Duuqnd
So, I'm making a command-line program in CL (sinful, I know). Is there a way to replace SBCL's own command-line arguments without changing the C code? I kinda don't want SBCL's usage text to come up when a user wants help about my program.
7:28:15
hayley
You could change the toplevel function to your own, and have it detect --help and similar.
7:28:39
jackdaniel
Duuqnd: for somewhat systematic approach for building cli tool check out the library net.didierverna.clon
7:29:02
Duuqnd
What would I need to do in the toplevel to stop SBCL from using the arguments? Just change the posix-argv variable?
7:33:23
jackdaniel
it works without cffi, it is needed only when you expect colored output (if I remember correctly)
7:36:38
Duuqnd
madnificent: --script is nice and all, but I'm hoping to have my program just be an executable and work as is expected.
7:41:31
madnificent
certainly possible. i vaguely remember having some scripts running on SBCL or ECL in binary form. i'm fairly sure i didn't distribute them. you could also start with a shebang and move to a binary later when you need it.
7:42:06
jackdaniel
madnificent: I've linked a library that automates all that in a systematic fashion, there is no need for a duct taping
7:44:45
Duuqnd
I was reading some parts of the Clon source to try to figure it out and I saw a comment that reads (paraphrasing a bit) "When a standalone executable is dumped, [only user-level options being present is] always the case" but that doesn't seem to match what I'm experiencing.
7:45:22
madnificent
jackdaniel: yeah, it's mentioned on the cliki page too. it was my impression that it felt too heavy right here.
7:48:40
pve
Duuqnd: If you use sb-ext:save-lisp-and-die, then you should provide your own toplevel function, like hayley suggested
7:50:18
Duuqnd
I'm doing that, yet when I type "--help" it's SBCL's usage message that shows up instead of mine.
7:52:21
jackdaniel
Duuqnd: I think that clon expects you to call a function clon:dump or something like that
13:16:12
JeromeLon
I want to find, remove, and return the first element of a vector that matches a predicate. DELETE is *so* close, but it doesn't return it. I could FIND and DELETE, but that's duplicating the work. The only solution I found is POSITION, followed by (DELETE-IF (lambda (x) t) seq :start position :end (1+ position)). This last bit gives me nausea. Can anyone suggest something less ugly?
13:17:02
JeromeLon
(I do know that delete does not garantee that my original vector contains the result)
13:23:44
JeromeLon
Bike: thanks! And thanks for suggesting replace, I'll use it instead of the DELETE, to change the original vector, it brings several improvements
13:46:41
Krystof
(defun find-remove-and-return (vector predicate) (let (result) (delete-if vector (lambda (x) (when (funcall predicate x) (setq result x) t)) :count 1))) ;?
14:05:52
Colleen
Function array-utils:vector-pop-position https://shinmera.github.io/array-utils#FUNCTION%20ARRAY-UTILS%3AVECTOR-POP-POSITION
15:08:23
JeromeLon
Shinmera: Thanks! I feels like a basic need, indeed. I see why you need this lib in several projects
15:10:16
Shinmera
not covered by the docs, but it also has a * variant that is O(1), but changes order of elements.
15:44:03
dieggsy
A while ago I think someone suggested a way to create a graph of class structure/inheritance - does anyone have any ideas? Allegro's composer has a utility for this, but it seems to crash on Emacs for macos (without X11). We have some custom method that user graphviz, but I'm wondering if there's a more straightforward or portable way
15:46:28
beach
As I recall, it's a command that starts with comma, like ,show-class-subclasses and ,show-class-superclasses
16:51:20
beach
That would depend a lot on the implementation of both Common Lisp and that other language.
16:52:14
lucerne
beach: Perl and Python both have one canonical implementation AFAI, and I am open to using any (free) CL, though I prefer SBCL.
17:26:54
Bike
please post descriptions of links you post if their content is not obvious from the url
17:27:06
lucerne
Xach: I currently just want a language (any language) that I can code once in, and use it anywhere. CL is one of the nicest langs I know, so I wanted this main lang to be CL. I guess I’d go with zig now.
17:28:03
Xach
lucerne: the easiest way to do that is to become important enough at a company or other organization that you can dictate technical details.
17:30:25
lucerne
But I do not want to duplicate some basic functionality between CL and Perl and others. I can’t afford that, being just one person 😄
17:30:55
Xach
I've been pretty happy simply ditching perl and using CL for everything, but it is a personal choice.
17:31:16
mfiano
Raku (formerly Perl 6) might be worth looking into, as it has a lot in common with CL, but this is off-topic here.
17:41:22
copec
It feels like there is an exponential explosion of new languages in the last 10 years
17:52:52
pjb
lucerne: you can use libecl.so and dynamically link it into any program, to use Common Lisp.
17:57:37
pjb
lucerne: but if you're afraid of the work, you can still avoid duplication by having two programs, one in perl and one in common lisp, and communicating thru a pipe or sockets.
18:10:55
jcowan
on IRC, it's morning when you join / start talking, and night when you leave / stop talking.
18:46:13
pjb
lisp123: well, I said that :around et al. are better reserved to client code, but actually this has a problem: if the client code adds a :around method on one of your class, this will also be called for other subclasses of yours, in other client libraries.
18:46:36
pjb
lisp123: so even client code may want to refrain adding methods on classes or subclasses that are not its own.
18:47:12
lisp123
pjb: I see. I earlier thought you had meant to use it to avoid changing any interfaces for the client
18:48:01
pjb
What those method do, is to wrap behavior in the right position even for subclasses provided by the client.
18:48:36
pjb
Always keep this picture https://pablofernandez.tech/wp-content/uploads/2011/08/common-lisp-method-composition.png
18:49:04
pjb
or this equivalent one: https://upload.wikimedia.org/wikipedia/commons/4/43/Method-combination.png
18:51:05
lisp123
Fortunately I only code for myself, so I will just stick to standard primary methods :)
19:03:10
pjb
lisp123: notice the cm and mc example (m is a "mixin", and depending on the order it's in the superclasses list, the order of the methods called.
19:04:21
pjb
lisp123: notice also with the cm example, the importance of (when (next-method-p) (call-next-method)) even in the inner primary method (in the superclass).