|
|
Badly-behaved targets, or: eev, Slime, Sly, and Maxima (2025)
- 1. Screenshots
- 2. Lots of links
- 3. Transcript
My main page on eepitch is here.
My main page on Maxima is here.
Its section on debugging Maxima is here.
To write edrxbox I had to use Slime and Sly a bit (or a lot).
This page needs a lot of work - but the transcript is finished.
The video was recorded in 2025dec16 and announced in 2025dec19.
The best way to play this video from eev is with `M-x
1c' - it is "2025badly".
0:00 Hi! My name is Eduardo Ochs,
0:02 I'm the author of an Emacs package called eev,
0:05 and this video is about some very technical things
0:08 about Emacs Lisp, Common lisp...
0:11 Sly and Slime, that are related to Common Lisp...
0:14 and Maxima is built on top of Common Lisp.
0:18 And... here is a very short summary...
0:23 when we are in a Lisp buffer -
0:27 in a _Common Lisp_ buffer...
0:29 and we insert a test block there...
0:31 There are several ways...
0:33 several variants of ways
0:34 to insert test blocks there...
0:36 and one of the ways inserts this big thing here.
0:40 And this video is going to be about this detail here.
0:45 This `-b' means...
0:48 that we are handling something that is `b'adly `b'ehaved,
0:51 something that is a `b'lack `b'ox...
0:54 that we will have to use special tricks to handle it...
0:58 and it also means `b'eware.
1:00 And... so: the video is about that `-b.'
`foo' and `$bar'
1:02 Imagine that we are...
1:06 writing some code in Common Lisp,
1:08 and we want to debug
1:10 each of the functions that we write
1:12 on-the-fly, as we write it.
1:16 I started with these two functions here...
1:18 note that my major mode is "Lisp"...
1:21 and if I insert a test block here,
1:24 with `M-x eeit', for `i'nsert `t'est block...
1:28 the default is this.
1:31 But we are interested in some variants here...
1:35 and if we run `M-x eeit'
1:39 with some invalid numeric prefix
1:42 it shows us several options.
1:45 The options are these ones here [in the echo area]...
1:47 let me copy them from the "*Messages*" buffer
1:50 to a comment... here...
1:54 and... I'm going to discuss some of these variants.
1:58 But I'm going to need a smaller font for that.
2:02 The most obvious variant is using `M-x eeit'
2:06 with no prefixes at all...
2:08 We get this, and it calls SBCL...
2:12 and I can test it in the obvious way.
2:14 For example, if we run this, it opens
2:18 a target buffer running SBCL here...
2:21 it loads this file, "o.lisp"...
2:23 everything went well,
2:24 and now I can test my function.
2:27 Now... the first interesting variant is
2:31 how to run this Lisp function in Maxima.
2:33 So... let me try. `M-3 M-x eeit'...
2:40 it inserts a different test block.
2:44 This thing here looks redundant...
2:46 we have two `load's...
2:48 we have to decide which one to use...
2:50 or we can leave both...
2:52 The thing is that....
2:54 sometimes we prefer this one because we
2:56 don't want to enter... to go from Maxima
2:59 to the Lisp interpreter inside Maxima...
3:03 and sometime we want to use this one
3:05 because we want better error messages.
3:08 But let me try. If I run this thing here
3:12 Maxima loads this file here, and everything is ok...
3:15 and this function here, that starts with a `$',
3:18 can be called from Maxima.
3:20 So if I run "bar(2,3);" the result is 23.
3:26 Uh, so... until now everything is quite simple.
3:31 But what happens if I run this prefix here, `4'?
3:39 `M-4 M-x eeit' gives me this big thing.
3:45 Let me show how this this thing works....
3:50 No, no. Sorry, sorry. I don't want
3:52 that one. I want the the other one, with `5'.
3:56 Uh, sorry, sorry, sorry... this one.
4:08 I'm going to uncomment these things here,
4:10 `3ee' and `4eee', because they're going to be useful
4:13 in this demo here...
4:16 These first three expressions here, they...
4:20 they create a Common Lisp expression... sorry,
4:25 a target buffer running Sly in Common Lisp...
4:30 Let's try. We have to wait a bit. Here: Sly...
4:38 These other three expressions create a target
4:42 buffer running Maxima, and it loads
4:46 a file that I have, that defines the way...
4:50 of connecting to a Sly server.
4:53 And this one is the mysterious part.
4:55 It has this `-b' here, that means that this
4:58 thing is a `b'lack `b'ox, and that I didn't know
5:00 a good way to handle that black box...
5:02 so I'm going to handle it in a special way,
5:05 in which a part of the work is delegated
5:06 to the user... so it also means `b'eware.
5:10 It means: user, please beware, you're going...
5:13 to have to do some special things here.
5:17 So... if I run this line here
5:20 it takes a few seconds
5:22 and it creates a target buffer
5:23 that is in the wrong place.
5:25 It's here, in that window,
5:27 and not at the window at the right.
5:30 Now I'm at the target buffer,
5:33 and I have to type `f9' to signal to eev
5:36 that this is the target buffer.
5:38 And it does this. The `eepitch-b' has saved
5:42 that the source buffer is here,
5:44 when I type `f9', it shows the target buffer here,
5:48 at the window at the right
5:50 and now everything is ok.
5:53 Now I have to do some
5:55 something very technical, that creates...
5:58 another buffer...
6:04 if I run this, `find-4eee-maxima-sly',
6:07 eev shows all the targets that I have now...
6:09 I can switch between all these targets.
6:12 So this is Maxima, that has loaded Slynk,
6:14 that is the thing that connects to Sly...
6:19 this is the target that was created by Sly
6:26 before it connected to Maxima,
6:28 and this is the part of Sly
6:30 that is connected to Maxima.
6:33 This function here, `find-4eee-maxima-sly',
6:35 that shows all these targets, is just
6:36 just for debugging and for explaining things...
6:38 it is not very useful.
6:39 And if I run this one, `find-3ee-maxima-sly',
6:41 it shows only these two targets,
6:43 the top one and the bottom one.
6:45 These ones are the ones that are useful.
6:47 The middle one is not - it is just a curiosity.
6:51 So these are the targets that I'm interested in...
6:54 And if I delete the other windows, and I...
7:00 use these functions here...
7:02 I can select between the other targets and show
7:05 only one target at the window at the right.
7:09 And typically I'm going to run this
7:12 to load this file here into Maxima from Lisp,
7:16 or I'm going to run this and load the... thing...
7:23 from Maxima.
Notions of simplicity
7:26 I gave a presentation at the Emacsconf 2025
7:31 nine days ago, and one of the main themes
7:35 of my presentation was different notions
7:37 of simplicity, and how eev is based
7:41 on a certain notion of simplicity
7:43 that makes all sense to me, and apparently
7:45 it makes sense to very few other people.
Lambdas for beginners broken
7:49 One of the slides was this one,
7:51 in which I compared how lambdas
7:55 were represented until some time ago
7:58 with what changed, and how lambdas were...
8:06 were changed to be represented internally
8:08 by some opaque objects that look like arrays, like this.
Mr. Jingles: My working memory is small
8:13 And another slide that I used was this one,
8:15 in which I tried to explain some ideas behind
8:19 my notion of simplicity.
8:22 And I said that "my working memory is small"...
8:25 So I need something that is is compatible
8:28 with not being able to memorize many things...
8:32 and I need examples...
8:34 and I make lots of mistakes when I type.
Links to the mailing list
8:40 And I added to this page several links to
8:44 messages from the emacs-devel mailing... to...
8:48 by Alan Mackenzie...
8:50 I have the impression that Alan Mackenzie
8:53 has a notion of simplicity that is very similar
8:55 to mine... and in this message here, 559,
9:02 he says that... he says something very similar
9:05 to what I say in my presentation... and I want to
9:11 discuss a part of one of these messages.
Section 4: Simple, elegant, etc.: links
9:13 One of the sections of my page
9:16 about my presentation
9:18 at the EmacsConf is this one -
9:20 section 4 at the moment...
9:22 And note that it starts with this.
9:25 My tendency when I think that I have to explain
9:27 my notions of "simple", "elegant", "fun",
9:30 "easy", "hard" and "overwhelming"
9:32 is to think that I have to explain all of them,
9:34 all these notions, in a few lines...
9:37 and that is too hard. One alternative
9:39 is to quote other people, and use links.
9:41 And in this section, I collected several links
9:45 to messages that Alan McKenzie
9:47 sent to the mailing list...
9:49 and I'm going to discuss one part
9:51 of one of his messages... this one, 349...
9:55 that is here...
9:59 this is the part that is interesting to me now.
One message: 349
10:04 With simple straightforward macros...
10:06 I have no trouble...
10:08 this lack of memory [of mine] makes
10:10 working with these macros and function in Emacs
10:13 arduous and unrewarding.
10:17 But if ... had been documented
10:20 to the the customary Emacs standard
10:23 I would have finished the task.
Why Sly?
10:26 Let me go back to my .lisp file.
10:28 Remember that these are the variants
10:32 of test blocks for Lisp files.
10:35 And remember that I'm using Sly here...
10:39 that is a fork of Slime that is much less popular
10:44 than Slime. Why am I using Sly here?
10:49 I started trying to use Slime,
10:51 but I had some problems... and these problems
10:54 are explained in the source code of this function.
10:56 So let's go there... `M-h M-f' goes to some links
11:06 for this function here... and this link
11:08 will take us to the source code of that function.
11:10 Let me go up to the comments... here...
`wait-for-hooks'
11:19 Some targets for eepitch... like `eepitch-sly',
11:23 and this other thing, that doesn't matter to us now...
11:25 are hard to write because things like this one...
11:31 doesn't work.
11:34 This part of the expression, `(sly)',
11:36 returns too soon, but Sly keeps running
11:39 and keeps doing things in the background,
11:41 including things that change the window configuration
11:44 and these things are done
11:46 outside the `(save-window-excursion ...)'...
11:49 so I don't have a way to control
11:51 what's happening here, and make sure that everything
11:54 is happening in a single window.
11:58 I sent these issues to the Sly developers
12:02 but they didn't answer in a very... useful way,
12:07 and in 2022, in 2022-dec-30, I finally found a way
12:16 to create a "shell-like function"...
12:19 that is something that eepitch expects...
12:22 that opens a REPL for Sly in the current window,
12:26 reusing a current Sly if possible.
12:28 The main idea was to
12:30 replace this expression here, the `(sly)'
12:35 inside the `(save-window-excursion ...)',
12:37 by something that only returns when...
12:42 wow, there's a typo here...
12:44 when a certain hook - this one...
12:46 when this hook here is run,
12:48 or when a timeout occurs.
12:51 It was a pain in the ass to write this,
12:53 it was several days of work...
12:56 but it works.
12:57 And I was never able to do something similar
13:00 for Slime because the code for Slime is not as
13:03 clean, it doesn't have that hook...
13:05 and I didn't have help enough for doing that...
13:11 and I gave up...
Slime as a black box
13:13 which is similar to what Alan Mackenzie says here...
13:17 he says: but if... (blah blah blah blah)
13:22 ...I would have finished the task.
13:26 That was my problem with Slime.
13:29 I discussed a bit the idea of "black boxes"
13:32 in my presentation at the EmacsConf,
13:35 and Slime was a black box in the sense that
13:38 I could open it, I could see the pieces,
13:40 I could see how they worked,
13:42 but it was very complex for me...
13:44 I couldn't understand that,
13:46 and I couldn't change it, or hack it...
13:49 in the ways that I needed.
13:51 So for some people that would not be a black box,
13:57 but for me that was _equivalent_ to a black box
14:00 in the sense that I couldn't hack it...
14:03 so I _declare_ that it is black...
14:07 that that black box is black in a certain sense.
14:10 _For me_ that box is black.
Maxima and Slime
14:14 Remember that here in this test block
14:17 for Maxima and Sly, we had one `-b' like this...
14:20 That means "black box", "beware"...
14:25 "the user has to type `f9' to indicate
14:29 that this is the target buffer"... and so on.
14:31 So the `-b' means many things, but essentially
14:34 it means `b'eware, and it's a place in which we
14:36 have to forget the problem that we are thinking of
14:41 and pay attention on certain things,
14:45 to type `f9' at the right time,
14:47 just to start Maxima, Slime, etc.
14:54 So, I was discussing this thing here,
14:56 "5.maxima+sly", and if we try
15:00 this variant here, "4.maxima+slime",
15:06 with `M-4 M-x eeit'...
15:11 we see that it has another '-b' here.
15:18 Let me delete the rest...
15:25 This test block is much worse than the other one,
15:28 because to start Maxima and Slime,
15:32 I need to type a series of `f8's
15:34 and there are two places
15:36 in which I have to pause, pay attention,
15:39 type `f9' at the right time, maybe answer
15:42 some other prompts, like a yes-or-no
15:45 prompt, or something like that...
15:47 So it is very distracting.
15:51 If you want to play with that,
15:53 maybe because you've stumbled on some things
15:55 that you would like to control with eepitch
15:57 but that look like badly-behaved targets,
16:00 my suggestion is: forget Maxima for the moment,
16:03 so: delete this,
16:06 and focus on this thing here:
16:08 eepitch blocks for Slime.
16:12 Remember that if we run `M-x eeit'
16:15 with no numeric arguments,
16:18 we get the default test block...
16:22 and if we run it with an invalid prefix argument,
16:24 we get this help message here...
16:29 And if we run it with this prefix argument, `1',
16:33 `M-1 M-x eeit', we get this... eepitch block here,
16:42 that calls Slime...
16:46 it has to do some tricks
16:48 for deleting all the buffers
16:50 of a previous instance of Slime...
16:52 then it has to... it starts Slime
16:59 with this `-b' here meaning `b'eware,
17:03 and then it selects the... Slime as a target buffer...
17:05 and so on.
Suggestion: start by Slime
17:07 So my suggestion is: try to understand this,
17:09 and... if it works, very nice...
17:13 if you would like to chat with me
17:16 then very, very, very nice, please do...
17:18 and at some point there will be
17:20 many other variants of that
17:23 for other things that I couldn't control
17:25 with eepitch until some months ago
17:28 because I didn't have this trick.
17:31 I think that I'm going to stop the video
17:33 at this moment because the other things
17:35 that I want to explain
17:37 will be better explained
17:39 by using just text, code, and screenshots.
17:41 So... that's it. Thanks! =)
|