libera/#commonlisp - IRC Chatlog
Search
13:08:25
gamaliel
Hi, common lisp newbie here. I was wondering whether there was a way to evaluate a quoted push statement. For instance, if I write (let ((a nil)) (eval `(push 2 a))), the eval statement fails, as it does not recognize 'a'. How could I express it so that (eval `(push 2 a)) makes a '(2)?
13:09:29
beach
gamaliel: You can't. Luckily, EVAL does not have access to the lexical environment. Only to the global environment.
13:10:25
lisp123
To add to that, this will work (for the reasons mentioned above) (let ((a nil)) (declare (special a))(eval `(push 2 a)))
13:10:58
gamaliel
Ok. I was trying to circumvent a recursion by crafting a nested loop in quotes, but got stuck when I had to do the inside statement which involved push.
13:11:34
phoe
if anything, you can defer computation using closures, like (let ((a '())) (lambda () (push 2 a) a)) - this returns an anonymous function that repeatedly pushes a 2 into some list, and then returns that list
13:15:00
gamaliel
Ok. I was just seeing if it was possible to generate unevaluated nested loops to create a list of combinations.
13:17:28
gamaliel
So, for example, to generate the combinations of 3 elements from {0,1,2,3,4}, I could write (loop for i from 2 below 5 do (loop for j from 1 below i do (loop for k from 0 below j do (list i j k))))
13:20:09
phoe
or rather, nothing that you'd commonly encounter in Common Lisp that's written commonly
13:20:52
gamaliel
Yeah, I'm very new to the language. Just tinkering around some exercise problems I found to practice.
13:21:12
phoe
iterating over three variables would be like (dolist (i (iota 5)) (dolist (j (iota 5)) (dolist (k (iota 5)) ...)))
13:24:35
gamaliel
That would be correct. I mean, it's quite readily solvable using recursion, but I wanted to challenge myself into the new parts of the language using a way to construct the loops unevaluated and collecting the final call afterwards.
13:24:58
phoe
at least, unless the requirement is to stay functional, I'd macro it away - write something that can expand into nested DOLIST or DOTIMES
13:28:35
phoe
but if you want it to be customizable at runtime then you have a slightly more involved problem to solve
13:30:49
gamaliel
The nested dolist seems like a very doable solution. I can modify it to use loop and it may just expand exactly the way I need it. Thank you!
13:32:50
phoe
gamaliel: the general way of thinking in CL is - if you need to operate on something in its raw, unevaluated form, then you most likely need macros
13:33:55
gamaliel
Ok. My experience doing that is limited to simple bquote() statements in R programming language for statistics courses. This will be a good refresher.
13:37:32
gamaliel
Something like this could be a start for the solution: https://plaster.tymoon.eu/view/2866#2866
13:40:13
gamaliel
Ok. I just planned to use it as an internal template. Recursive macros are really mind-boggling for someone who has only programmed in other languages.
13:41:10
phoe
recursion is recursion - remember to check your termination conditions, and try to expand your macros one step at a time
13:41:38
phoe
macro writing is basically writing pure functions that transform one soup of conses and symbols into another soup of conses and symbols
13:54:30
Xach
empwilli: rainer joswig has a funny post about running lisp on his macbook air m1 6000x faster than his symbolic hardware, and consuming 6 watts vs 1KW for symboilcs
14:04:41
Bike
::notify pillton "I think there should be another operator or operators introduced which either avoid using AREF or ensure that every call to AREF does not require checking its arguments." what do you mean?
14:52:45
ns12
beach: I'm planning to learn an architecture in more detail. Just wondering if there is anything that's better for Lisp.
14:55:22
beach
I recommend you learn RISC-V. Not particularly for Lisp, but because it is clean and it could very well become widespread.
14:57:27
Bike
i mean, what did lisp machines have that was so great for lisp? 36 bit registers so you could store a 32 bit integer with tag? everything's 64 bit now anyway
14:58:01
Bike
i wouldn't be surprised if some architecture changes could make things easier for lisp, but as far as i can tell it's not a huge deal
15:09:54
semz
As in, they're performed while the actual computation is done, so that a successful check doesn't come with a performance penalty
15:15:52
semz
On a current machine, e.g. an unchecked array access is faster than a checked array access, even if the index lies within bounds, because the check comes before the access. Iirc on a Symbolics, both would be performed in parallel, and if the index lies in bounds, things would just carry on as if the check never happened.
15:35:01
lisp123
When I paste into plaster.tymoon.eu, the indenting is all wrong. But in Emacs / GitHub, it is fine. Does anybody know the setting to fix this?
15:35:47
lisp123
Its either something to do with spaces/tabs or some sort of hidden / incorrect space characters on my end
15:36:24
semz
Is it correct when you open the raw view? Might be your browser collapsing spaces. Lisp code usually is spaces-only so I doubt it's tabs.
16:02:57
rotateq
hehe in another german channel on libera with mostly also autistic/asperger people i sometimes express things in CL code and now some girl asked what i would would speak: "elisp?" :D no ANSI CL it is with full steam! even not write, but THINK in it
16:08:14
rotateq
edgar-rft: again, you bring it wisely to the point (now i hide from the ontopic police)
16:16:56
Josh_2
edgar-rft: You joke but this really is a massive barrier to entry for people :facepalm:
16:21:39
Josh_2
beach: apparently not. People seem to get very upset when someone says "uh if you cant learn emacs how are you gonna learn lisp?"
16:24:50
lisp123
Josh_2: I find its always a similar type of complainer. (1) Emacs, (2) Standard not updated, (3) GUI, (4) Some random obscure detail, (5) etc. I don't think beginners actually complain that much, but its just the similar type who rather make excuses than actually program
16:25:20
Josh_2
Something like that, at the end of the day it seems to boil down to not liking the parens
16:25:54
Josh_2
seems to me that its easier to evangelize to people who have never written code but wish to learn, I had this experience yesterday irl
16:26:53
Bike
i don't think it's unreasonable to want to use an editor you're familiar with. if someone told me i had to use some specific program to use haskell i'd certainly be less inclined to learn and use haskell.
16:26:58
lisp123
Yeah, exactly. Its something to do with Lisp, because as far as I can tell from reading historic sources, this was an issue since the 90s
16:27:44
lisp123
For some reason it attracts this certain type of individual as well (apart from all the good and productive lispers out there)
16:28:48
lisp123
Bike: But VSCode / Atom has a Lisp plugin. And most IDEs take time to get used to. And there is always LW personal edition for those who want something more 'modern' in terms of keybindings
16:31:16
Bike
if you can write lisp in something else, great. but condescending to someone who doesn't want to learn a new editor on top of a new language is silly.
16:31:25
lisp123
Swift requires Xcode, I (assume) Java is best done in JetBrains, most Microsoft languages (assuming again) are done in Visual Studio ~shrugs~
16:36:03
lisp123
Bike: I don't think people say that comment to beginners, if so, yes its not good to be condescending
16:38:17
aeth
maybe the equivalent would be macro-heavy code where you basically need to expand macros to see what's going on
17:30:34
Josh_2
Oops, having that annoying problem with connecting to my remote lisp, I remember writing the solution in here but now looking through the logs I cannot find
17:36:09
luis
not yet as plug-and-play as the original commonqt was, since there's no precompiled binaries available yet.
18:28:39
Guest74
my only problem with people saying use emacs for common lisp because it 'indents properly' is that you get a rude awakening when pasting stuff because emacs by default does not indent CL properly since it sticks in a bunch of tabs.
18:31:01
aeth
It also doesn't indent properly without SLIME, and without the libraries in question loaded into an active SLIME REPL
18:31:15
aeth
because it uses some things like the distinction between &rest and &body to inform its indentation
18:31:46
aeth
and without loading the library, it's going to assume that the macro is a function unless it's a COMMON-LISP built-in
18:32:32
aeth
Forgot to Quickload it before modifying it? Well, that means that you've just messed up your file's indentation.
18:53:23
Guest74
phoe: if I steal your rotation stuff you did for imago what would be the best way to credit you? Mind you I still haven't looked at it.
18:55:16
Guest74
I guess I can stick that in the commit message? It seems like a comment in code isn't sufficient attribution, at least in my mind.
18:56:17
phoe
also be cautious not to take too much imago code along the way if your code isn't LLGPL
18:57:11
Guest74
yes, I'll do both. I guess I should probably have asked a more git specific method of attributing a commit to someone else. Though I'll probably have to change the code somewhat as all my stuff uses linear arrays.
18:57:50
Guest74
rotations is the only thing I don't have(besides 90 degree rotations/mirroring), and everything is lgpl.
19:01:00
Guest74
just took a look, looks like I can just change a few function names and it should work as is.
19:03:08
phoe
Guest74: remember to grab the updated code from imago and not from my commit, there were some fixes made later on
19:37:00
Josh_2
I used to use http://wiki.c2.com/?ImageBasedLanguage but the site appears to be dead :cry:
20:02:50
nij-
Hi! I'm using sly in emacs. However, its completion doesn't work. When I do M-x sly-next-completion, a message says "No buffer named *sly-completion*." Anyone had this issue before?