freenode/#lisp - IRC Chatlog
Search
17:22:28
pve
at some point I'd like to give one to my son, but I fear he's still a bit too young for CL :)
17:33:15
aeth
pve: Probably too low-level but you could probably hack together some 80s-style 2D game that he can just modify
17:53:32
phoe
We have CL:CONSTANTP that accepts a Lisp form and a lexical environment, and answers true or false. Is it generally possible to have a hypothetical CONSTANT-VALUE operator that produces a value off a form that has been declared constant by CONSTANTP?
17:57:50
jackdaniel
i.e ecl's compiler has a function constant-value-p which returns two values: whether it is a constant, and if it is, the second value the value
18:02:02
aeth
phoe: Portably, I guess could do something like this, which doesn't have an environment, but I think the only portable DEFCONSTANT is global, anyway: (and (constantp '+foo+) (symbol-value '+foo+))
18:03:03
phoe
aeth: portably, yes, but if an implementation answers that e.g. '(+ 1 2) is CONSTANTP, then it should be able to fetch that value
18:03:33
phoe
I'm asking because I'm verifying my comment at https://www.reddit.com/r/lisp/comments/kob7hd/compiler_macros_when_why_how_and_real_life/
18:03:37
jackdaniel
constant may be defined in the compilation unit (but not really evaluated), that's another gotcha (then symbol-value won't work)
18:06:06
phoe
that's where the hypothetical CONSTANT-VALUE function comes into play, but I have no idea if there even exists a portalib for it
18:08:31
aeth
phoe: maybe something like this? (if (and (symbolp foo) (constantp foo)) #| the fast path using (symbol-value foo) |# #| the slow path |#)
18:09:02
phoe
basically https://github.com/Clozure/ccl/blob/553c0f25f38b2b0d5922ca7b4f62f09eb85ace1c/level-1/l1-utils.lisp#L680-L684
18:09:58
aeth
Well, I guess not because CL:+ is package-locked in SBCL and perhaps other implementations.
18:11:50
aeth
phoe: That doesn't help the general case, only with CL:+, which was poorly chosen on my part. Unless the package you're using is package locked. It looks like Alexandria has this... #+sb-package-locks (:lock t)
18:12:09
phoe
aeth: the general case is that I have a form, and an implementation tells me that this form is CONSTANTP
18:12:11
aeth
Idk which implementations other than SBCL implement the feature sb-package-locks, though
18:12:43
phoe
possibly using implementation-dependent functionality, because it's required in the general case
18:13:06
aeth
But a tree-walk only works if it's package locked, otherwise it could stand for anything.
18:19:19
aeth
phoe: I guess SYMBOLP is the only thing you can do portably for the portable path, then? Since that's just global. i.e. (and (symbolp '+foo+) (constantp '+foo+)) then (symbol-value '+foo+)
19:10:38
MetaYan
The sb-cga issue that's been causing many failures in the Quicklisp reports now has a fix: https://github.com/nikodemus/sb-cga/pull/8 . Does anyone here have the possibility to merge it?
21:10:54
makomo
does anyone have a recommendation for a library that implements a mutable ordered set?
21:11:52
makomo
it's a bit annoying how fragmented the ecosystem is when it comes to data structures :/
21:13:50
makomo
shka_: i've taken a look at cl-data-structures :-), and was just about to ask you a bit about it. does the set interface have just those 3 functions? what about unions, intersections, differences?
21:15:24
Alfr
phoe, ah okay. It's insertion order, not inventing some H respecting < for every problem. Didn't know about it, thanks.
21:16:16
shka_
makomo: i certainly want to add unions, intersection and difference, i just didn't manage to get to it yet
21:21:24
shka_
if you want to contribute to the development of cl-ds, you are encouraged to implement the set intersection for skip-lists ;-)
21:27:39
makomo
shka_: is there some sort of reference that you used while implementing the skip-list-based set or?
21:32:38
shka_
it is not particularly complex data structures, erase proved to be the most difficult part
21:43:30
shka_
but honestly, after you get the basic property of the one into your head, you can figure out the rest
21:48:36
mfiano
balancing red-black trees is quite easy compared to other rebalancing such as AVL/WAVL
21:49:16
mfiano
Also, all self-balancing trees can be written in terms of 2 functions split and join, with the rest of the code shared among all implementations.
21:51:29
mfiano
Maybe people should write tests to ensure the invariants. The algorithm is quite simple
21:52:19
mfiano
Also, for the split/join awesomeness, have a read this paper which is what I did for RB/AVL: https://arxiv.org/pdf/1602.02120.pdf
21:56:35
mfiano
I guess I recalled incorrectly: "all code except JOINisgeneric across the balancing schemes
21:58:45
contrapunctus
I'm trying to write a Gemini CGI script. (I'm new to Gemini, web programming, _and_ CL. 😅) This is not a long-running application - does the "connect to remote Lisp image" workflow still make sense for it? 🤔
21:59:33
shka_
contrapunctus: i honestly don't understand your question, but connecting to the remote lisp is normally very useful
22:01:26
contrapunctus
shka_: most of the examples I've seen for remote interaction have been of programs with a constant event loop of sorts running.
22:02:21
shka_
contrapunctus: well, for what is worth i used to connect to the remote server with a decent hardware resources to crunch some data
22:04:44
contrapunctus
shka_: what did your workflow look like? Start remote SBCL (running swank), create SSH tunnel, and M-x slime-connect, each time you want to work on it? 🤔
22:11:28
benjamindc
When I try to load my asd file I get an error: Execution of a form compiled with errors. Form: ("alexandria"). But when I prefix defsystem with asdf (e.g. asdf:defsystem), I don't get that error. But I see that it's standard not to use the prefix on code that I see on github. What am I doing wrong?
22:12:43
Xach
Also, I wouldn't say it's standard not to use the prefix - that is a way around the very problem you have.
22:15:50
benjamindc
Now I'm having the problem that when i run (asdf:test-system "systemname"), rove runs successfully, but doesn't run any tests.
22:21:54
Xach
a table would be faster but longer to make - i can't think of a well-known short idiom
22:24:41
frodef
In terms of efficiency I could easily whip up a simple loop, but I don't think it would be more readable/idiomatic.
22:25:16
phoe
if it's eq or eql or equal or equalp I just add them into a hash table and return NIL if there's a FOUNDP
22:26:06
semz
If a function converts something to a string, is it ever a disadvantage if the resulting string has a fill pointer? I find the function much easier to write using FPs and feel it'd be silly to copy the entire thing just to end up with a simple-string.
22:26:49
phoe
semz: mostly speed I think, some code is more performant if it knows that it works on simple strings
22:27:34
frodef
semz: I can do a helper function, just that if there's already such a function or idiom, that'd be better.
22:28:32
Xach
semz: yeah, working on arrays with fill pointers is slower in general. if a consumer cares, it would have to convert.
22:31:29
Xach
It can still be the right choice for you! It just helps to be aware that it's not without drawbacks.
22:36:15
phoe
CONSTANTP question: could someone provide me an example where the &environment argument passed to CONSTANTP matters? Like, where it changes the actual outcome of the function?
22:37:46
frodef
I guess an env could hold e.g. a symbol-macro that transforms a symbol to e.g an integer?
22:48:08
semz
(cons x y) has duplicates iff y contains x or y contains duplicates, so it's enough to check cdrs
22:51:35
semz
once you've checked for 1 in '(1 2 3), there's no need to check 2 against all of '(1 2 3) again because (test 2 1) = (test 1 2) was already done earlier
22:56:01
semz
i'm going to shamelessly use this as an argument that my solution trips less people up :-)
22:59:21
Xach
you could tweak it slightly to (loop for (item . rest) on list thereis (find item rest ...))?
0:37:19
charles`
When I call "error" it only give me the abort option. if I want options like "continue" or "retry", do I have to make my own condition?
0:39:34
frodef
for example: (with-simple-restart (continue "Never mind.") (error "I don't know what to do!"))
0:46:29
frodef
retry: (loop until (with-simple-restart (retry "Have another go") .. (error "huh?") ... (compute-non-nil-value)))
0:58:39
frodef
w-s-restart often does the trick, but sometimes restart-case or even restart-bind is the way to go.
0:59:52
charles`
and what if I want to use my custom ones with the default continue, should I nest them?
1:06:31
frodef
The function CONTINUE will go to the innermost restart called continue. But any decent interactive debugger will let you chose which exact restart (inner or outer) you want.
1:07:53
frodef
programmatically, see COMPUTE-RESTARTS. You can invoke any one of them, regardless of what they are named.
1:12:43
frodef
The magic is just in the framework, or the ideas behind it. Having proper restarts available can make or a beautiful system.
1:14:19
frodef
Usually RESTART-CASE, but RESTART-BIND if your restart would benefit from the dynamic context of the error.
1:16:30
frodef
These are really some of the most profoundly and uniquely beautiful corners of CL, IHMO.
4:00:05
sauvin
Ubuntu installed a pile of cl-* files when I installed Common Lisp but I have no idea how to load or use them. Figuring out how to use them is my problem, but could anybody help me with using them and/or with a package manager? Quicklisp doesn't seem to like gcl.
4:03:00
no-defun-allowed
I don't know how to use the Ubuntu (or Debian) packages (though you could always try locate to find them), but you probably don't want to use GCL these days.
4:03:14
contrapunctus
sauvin: by 'installed Common Lisp' do you mean installed gcl? What did gcl say that makes you think that Quicklisp doesn't like it?
4:03:42
aeth
I'm not an Ubuntu expert, but you generally don't use the distro packages for languages that have their own package manager. They're mostly for dependencies of things that the distro ships, like e.g. Maxima.
4:04:13
no-defun-allowed
Oh, looking at the file listings, they are stored in /usr/share/common-lisp/source/ but I don't know what you do with them. If you installed ASDF from the package manager, it might know to search there for systems, or it might not.
4:04:15
aeth
If GCL isn't complete enough to run Quicklisp, it probably can't run any of the libraries, either. e.g. I think its CLOS is incomplete.
4:05:44
sauvin
contrapunctus, it won't load the quicklisp.quicklisp in /usr/share/..../quicklisp, complaining about ASDF.
4:06:52
sauvin
aeth, what you're saying is familiar to a perl person. I'll take the risk, but I'd really like to check out this pile of cl-* files that Ubuntu put on the hard drive but I'm at a loss for loading.
4:08:53
sauvin
If this stupid thing vexes me much longer, I'm gonna say "screw you" and start using sbcl.
4:09:34
sauvin
I _usually_ like gnu stuff and don't know enough about lisp - ANY recent implimentation - to make anything like an informed choice.
4:09:46
aeth
I'm under the impression, perhaps mistaken, that GCL was never completed. Even CLISP is a more mature GNU CL, but CLISP hasn't had a release in 10 years.
4:10:14
aeth
But generally people use SBCL, CCL, or ECL, I think. A bit of ABCL (on the JVM) in here.
4:10:49
contrapunctus
sauvin: this guided me in my choices as a newcomer to the CL world, hope it helps you too - https://github.com/emacs-tw/awesome-emacs
4:12:10
benjamindc
does anyone know why the asdf package-inferred-system class doesn't work with pathname?
4:12:23
aeth
GNU has two CLs (CLISP and GCL) and maybe 3-4 Schemes (Guile, Kawa, MIT/GNU, and I'm sure they have another one or two hiding because Schemes are common)...
4:13:04
aeth
but unfortunately, neither of the CLs are that active. CLISP's last release was 10 years ago. GCL's was 6. Meanwhile, SBCL's on a monthly release cycle.
4:14:09
sauvin
Everything you're telling me, though, suggests I oughta spend a few minutes rethinking my cathexis to gcl.
4:14:43
no-defun-allowed
How fast can you say "Eh, maybe not then?" You need about that long to make a decision.
4:16:27
beach
sauvin: I don't know what it means to be a "Perl guy" or any "<tool> guy". You should learn the tools that will make you the most productive. It is not personal.
4:17:16
sauvin
I didn't take it as a personal affront, but one also uses what one knows, especially since this is strictly armchair stuff. My day job is "forklift driver".
4:18:14
aeth
sauvin: I don't remember where I saw the original, but I made a few modifications iirc...
4:18:34
beach
sauvin: That is the wrong attitude. If one always uses what one knows, then one will never learn anything new.
4:18:53
aeth
sauvin: But I just use the rlwrapped SBCL as a fallback. It's no replacement for SLIME.
4:19:25
sauvin
Probably not, but I think I'll learn a few things about the language itself before simultaneously wrestling with an unfamiliar editor.
4:20:13
aeth
sauvin: but if you absolutely need built-in readline, then CLISP will probably be a bit less painful than GCL, although it's increasingly common not to support it with libraries
4:20:15
sauvin
On the subject of which, is there a way to use emacs lisp without also having to use emacs itself? O:)