libera/#commonlisp - IRC Chatlog
Search
7:06:13
dmho
Hey I couldn't find a plug-n-play way to 'visually' align string literals to make them look aesthetically pleasing in an Emacs buffer, and since I don't know emacs and elisp all that well I thought I'd see if chatgpt could lend a big helping hand in making this idea a reality.
7:06:30
dmho
The result is string-literal-visual-align-mode! It adds an overlay to your emacs buffer for every multi-line string literal, that effectively indents/aligns the start of the line with the opening quote without inserting characters into your file. https://pastebin.com/raw/cGaNdczE
7:09:19
dmho
just `(require 'string-literal-visual-align-mode)` in your emacs init and add `(add-hook 'lisp-mode-hook 'string-literal-visual-align-mode)`to enable it for lisp files and you're good to go!
7:37:36
elderK
Hey guys! I was wondering when exactly we need to use eval-when. For instance, if we defin a macro that we want to use in another macro, does the macro we want to use in a macro need to be defined with in an (eval-when (:compile-toplevel :execute :load-toplevel) ...) form?
7:38:17
elderK
The same question applies to type abbreviations defined using deftype: If I define a type abbreivation that I want to use in a macro, does that abbreviation also need to be in a suitable eval-when form?
7:39:14
elderK
What steps do I need to do, to ensure that if I have a macro, that the macro can be used "in all times." Is that even wise? CLtL2 has an example where a macro is defined but isn't valid when used, in a case where I thought it would be.
8:02:01
beach
elderK: The standard says that the macro is defined in the "evaluation environment" by the compiler at compile time, so it is available for further processing.
8:06:30
beach
dmho: Nice! I use #.(format nil "...") myself so that I can use ~@<newline> and then indent the following line without the string actually containing the indentation.
8:10:04
beach
elderK: However, if a macro function uses an auxiliary function for its expansion, then, if you use the macro at compile time, that function must also be defined at compile time. And DEFUN does not automatically define functions in the evaluation environment, so you need EVAL-WHEN then.
8:51:18
beach
dmho: See for instance the last form of this file: https://github.com/s-expressionists/Constrictor/blob/master/Code/assoc.lisp
9:18:32
dmho
beach: That's pretty neat, and has the added advantage of being aligned when not viewed in an emacs buffer.
9:22:11
dmho
A pitty no control code exists for "newline and delete up to char" then one could have the best of both approaches.
9:22:21
beach
Notice also that I use (SETF DOCUMENTATION) to avoid the noise inside the entity being documented.
9:22:22
elderK
Any chance we have a "distribution" of the CLHS for eReader devices such as a Kindle? Many years ago, I purchased CLtL2 for Kindle from HP Technologies. It was very expensive and it has serious issues as they did a bad job translating it. But, it was useful since I often read on my Kindle device.
9:22:44
elderK
I wonder if there is a TeX renderer for ePub. It'd be neat to peruse CLHS in bed :P :D
9:23:22
elderK
I have the CLHS available locally here, as well as a rendering of the CL ANSI Draft. I just wish they were easier to read on a more mobile device.
9:23:46
beach
elderK: The Common Lisp HyperSpec is not being worked on, and you are not allowed to modify it. You might have better luck with NovaSpec by gilberth.
9:25:40
beach
Or you could compile the dpANS TeX sources from scratch, perhaps with modified page parameters. But you wouldn't have hyperlinks then.
9:26:28
elderK
beach: How complete is the Nova Spec? I've seen several different renderings of the spec, all of which seem to be in a different state of completeness. Is the Nova Spec effectively complete?
9:28:52
elderK
As for the CLtL2 version for Kindle: Avoid it unless you have no better choice: They don't have the entire document "linked" properly. So, there's no index: Only a single "index" for the ToC which itself, does have hyperlinks. The result is that you have to go to the TOC, go to some place you want, read for awhile, then jump back to the TOC and stuff.
9:29:58
elderK
I've read that purchasing the official ANSI spec for CL is pointless too, as the quality is terrible: Just a scan rendered as a PDF.
9:30:38
beach
Yes, apparently ANSI lost the sources. But you can create PDFs (by chapter) from the dpANS.
9:33:45
elderK
Just wondering as I'm curious how to specify that I want "my code" to be compiled without any kind of optimization, the hope being that the debugger will give me better information and maybe let me step through forms.
9:33:51
beach
gilberth is the best hacker I have ever run into, and he is a perfectionist, so you can count on the stuff that he releases as being quite good.
9:34:06
elderK
I'd be afraid to set the qualities like, in a startup script, since that would also affect all the code I load, right? Say, dependencies.
9:36:29
elderK
Thanks beach! Hopefully that'll make the debugger more useful. I find that when I have a break, for instance, I have no restarts for stepping.
9:37:09
beach
elderK: I know what you mean. Debugging with free Common Lisp implementations is not great as my paper describes.
9:37:40
beach
Check the section on existing work in this paper: http://metamodular.com/SICL/sicl-debugging.pdf
9:37:42
McParen
i'm looking for a name for a function that does something similar to emacs' "fill-paragraph", but I dont want to name it to "fill", because that sounds quite random, is there a better word for what that function does? (word-wrap and mangle multiple spaces to one)
9:41:43
McParen
beach: the use is formatting long lines to pargraphs with shorter lines. when the spaces between words are kept as given, it is just "wrapping", but when multple spaces are collapsed to one, it is caled "filling", but i'm looking for a better, more intuitive word for that.
9:43:49
McParen
beach: not on an editor, but on an irc client, which also has to wrap lines. i first had a function that collapsed multiple spaces because that was easier to write, but then i noticed that this basically reformats user input, which is kind of wrong. so i rewrote that but dont want to throw the original function away...
9:45:09
McParen
i'm probably going to keep "fill-string", but only if there is no other common word for it.
9:46:26
McParen
beach: yes, i'm awayre, but i'm a fan of terminal clients, so i am working on a TUI one.
9:47:19
McParen
elderK: "wrap" does not imply collapsing multiple spaces, i'm looking for a word to describe "foo bar baz" => "foo bar baz"
9:50:17
McParen
elderK: yes, these are all valid suggestions, i wondered if there is maybe some common term that is also used in the wild.
9:50:25
elderK
beach: Potentially dumb question here but is there any reason why a macro can't be recursive? Like, it expands to a simpler call of itself?
9:52:12
beach
elderK: The macro function can use the macro for its expansion, or the macro function can generate code containing the macro.
10:07:29
elderK
beach: The part that I found interesting is "3.2.3.1.1 Processing of Defining Macros"
10:08:52
elderK
I would've thought that the macro would be available to all future forms that the compiler compiled. I would've also assumed that the macro would be available when say, you redefine things at the REPL. I guess the reason it seems to be that way for me, is that SBCL is always compiling, right?
10:09:55
McParen
emacs does not seem to have an explicit function to just word-wrap text without also "deleting any excess spaces". both of these actions are together named "filling". but the emacs display engine does word-wrap text preserving multiple spaces when for example the emacs window is resized. it just doesnt seem to have a function to explicitely do this to a string argument.
10:10:54
beach
elderK: If the defining macro is DEFMACRO, then the macro is available to the compiler from the time it is defined.
10:12:00
beach
I mean, if the defining macro is DEFUN, DEFVAR, or DEFPARAMETER, then the function/variable is not available at compile time.
10:12:04
elderK
beach: When we build a project using ASDF, are all the files built together in a single compilation unit?
10:12:51
beach
elderK: So if you define a function in one file you can use it at compile time in a subsequent file.
10:14:53
elderK
I think I need to learn more about the different environments (startup, compilation, evalution and runtime.)
10:14:59
elderK
"Figure 3–8 lists macros that make definitions available both in the compilation and run-time environments. It is not specified whether definitions made available in the compilation environment are available in the evaluation environment, nor is it specified whether they are available in subsequent compilation units or subsequent invocations of the compiler. As with eval-when, these
10:15:01
elderK
compile-time side effects happen only when the defining macros appear at top level."
10:16:00
elderK
The way I figure this, is that if you compile file A and file B, but don't load A after it is compiled, then during compilation of B, the macros you defined in A may not be visible. May or may not.
10:17:21
elderK
The standard doesn't say that A's changes are not visible to B, just that we can't rely on it, unless A is loaded after it is compiled and before B, right?
10:17:45
beach
Most Common Lisp implementations don't have an evaluation environment that is distinct from the start-up environment.
10:18:11
beach
So the standard does not require that, because that would mean a total rewrite of most Common Lisp systems.
10:18:18
elderK
If you call compile-file from the REPL, does that mean the startup environment is the same as the runtime environment? And if so, doesn't that mean the compilation environment is the same, too?
10:19:08
beach
And in (almost) all Common Lisp implementations, the evaluation environment is also the same.
10:19:32
elderK
I guess these distinctions are made so that you could have a batch compiler for CL that isn't interactive at all?
10:19:41
beach
The reason for that is simple... Most Common Lisp implementation do not have explicit representations of environments.
10:20:45
beach
I see the distinction between the startup environment and the evaluation environment as something that is desirable, but that they didn't require when writing the standard, because then every existing Common Lisp implementation would have to be rewritten.
10:20:49
elderK
Aye: I wish CL had proper first-class enviroments as described in your paper. It seems to me that it would make the package system, and even the idea of a module system, way more awesome.
10:22:08
elderK
evaluation environment is where stuff that executes as the compiler compiles, occurs, right? So, if the startup and evaluation environments are distinct, that means you could set up new readtables, do a bunch of crazy modifications and once compilation was done, those changes would not influence any further compilation or the system at all.
10:22:14
beach
I would like for the file compiler to have no lasting effects on the startup environment.
10:23:46
beach
Well, there is still the issue that the compiler can use the contents of the startup environment, so for reproducible builds, you need to make sure the startup environment is the same.
10:29:52
beach
elderK: Let me know when you are ready to help create a Common Lisp implementation that solves the environment issues and that allows you to use a real debugger to debug your code. :)
10:32:23
elderK
The other day, I did something I thought would be too hard for me and it was really fun. I took a look at the "trivia" pattern matching library and decided I wanted something similar for my own use. And, I managed to do it :)
10:33:06
elderK
I've been working through the book "Essentials of Compilation" by Jeremy Siek: Some AST transformations are very difficult if you do not have pattern matching so, that's why I decided to do the little matcher. I'm not sure how "good" it is yet but I am working to learn more and improve more.
10:34:22
elderK
I still have no real sense of how "expensive" things are: So, for my pattern matcher expansions, for instance, I don't know if having a lot of nested (when ...) is better than a lot of (let (...) ...) or not. Or, if I have an extra (progn ...) here or there is going to be a potential performance thing. In most cases, I figure not as the compiler proper will cull them.
10:35:03
elderK
Another thing I am still having trouble with - and I'm not sure why - is how to organize my work. Lisp is much more free-form than I am used to with where you put stuff, or the conventions for where you put stuff. So, I am finding it hard to get a good footing on well, how I like things to be laid out.
10:36:05
elderK
beach: No ETA for now. If I could commit to doing Lisp every day instead of work, I would say "now."
10:38:25
elderK
I wish I could as I am finding it increasingly difficult to work on something I no longer feel passionate about: The actual technical stuff of what we do, the problem, is interesting but I find the way we are actually solving things to be not so much. Processes have been changing and the result is that, well, the work isn't as satisfying or rewarding as it once was. But, for now, I hesitate to
10:38:27
elderK
leave because you know, the "recession." I'm also concerned that if I did leave, I wouldn't be able to find another job, either due to bad job market or due to the fact that I have had wrist issues.
10:39:43
beach
elderK: I have some advice about the workplace stuff, that I applied myself when I worked in industry...
10:40:27
beach
elderK: Basically, the literature on software engineering recognizes that there can be a factor 20 difference in productivity between two developers with the same training and the same experience.
10:41:05
beach
This means that employers can't tell the difference between someone working 40 hours per week and one that works 2 hours per week (I am exaggerating a bit).
10:41:33
beach
Furthermore, employers usually don't allow employees time to learn new stuff and experiment with alternative solutions to problems.
10:41:57
beach
This a big mistake on the part of the managers, because then they are not doing the job they are paid to do.
10:42:26
beach
So I recommend taking (at least) half a day per week to do personal stuff, paid by the employer, of course.
10:42:44
beach
In your case, it could be to try to use Common Lisp to solve those interesting problems you have.
10:43:41
beach
My case was very similar at the time. We were using the wrong languages, and I showed how using Lisp (not Common Lisp at the time) made things much easier.
10:45:15
beach
And in many situations, the employer doesn't care much what techniques you use to solve their problems, and in those situations, you could use Common Lisp in some cases.
10:46:46
beach
So if you assume you have average productivity, taking 4 hours per week for personal stuff won't be noticed. Then those 4 hours will allow you to learn things that make you even more productive, so you could use that to take even more time for your own activities.
10:47:30
beach
It is of course best if your activities are related to your job, but even if they aren't, you are going to learn stuff that will make you more productive for the job-related activities.
10:48:05
elderK
That's good to know: I've generally been the kind of person that works, in my view, 110% at whatever task I'm given. Mostly that's been because of lessons my parents taught me and also because, you know, I feel guilty if I am not "on task."
10:48:34
elderK
Of course, that has probably led to the wrist issues. I can't talk more about that stuff here though, just in case someone from work *is* here.
10:51:16
elderK
I find that if I make progress on personal projects, I tend to be a lot happier. If there are weeks where I make no progress, or cannot create "safe time" for the projects, I just get grumpy. I'm not sure if that's normal for programmers or not.
10:52:26
elderK
At work, I find that I feel increasingly resentful. Not necessarily of the company itself or even if resentful is the right word. I want to like, do a good job, you know? I want to make the system better, and see it improve. Instead, I see many processes that just reduce efficiency and restrict my ability to make things better. For a time, I thought it was just me and I was being a bad team
10:53:11
elderK
I was also worried that, you know, maybe I was just being a jerk and expecting too much because I don't want to spend 8 hours a day doing work I know isn't my best or isn't allowing me to improve in a way I feel is important.
10:53:40
elderK
I don't want to be a bad employee or a bad team member, so, I'm trying to resolve it internally as best I can.