libera/#commonlisp - IRC Chatlog
Search
0:54:06
yitzi
Please note in the definition of evaluation: "...such execution might be implemented directly in one step by an interpreter or in two steps by first compiling the form and then executing the compiled code; this choice is dependent both on context and the nature of the implementation, but in any case is not in general detectable by any program. ..."
0:56:44
pillton
From CLHS 3.1: Evaluation: "Evaluation is the process by which a program is executed in Common Lisp. The mechanism of evaluation is manifested both implicitly through the effect of the Lisp read-eval-print loop, and explicitly through the presence of the functions eval, compile, compile-file, and load. Any of these facilities might share the same execution strategy, or each might use a different one. The behavior of a conforming program
0:56:44
pillton
processed by eval and by compile-file might differ; see Section 3.2.2.3 (Semantic Constraints)."
0:57:12
pillton
Years ago you could type clhs 3.1 and a link to the standard would be posted in the channel by a bot.
1:02:53
nij-
For example, I would expect that (funcall (compile-file (lambda () FORM)) should have the same behavior of (eval FORM).
1:03:05
pillton
Of course it specifies their semantics. It has a definition of a conforming program.
1:03:48
yitzi
In general, the spec leaves ambiguity where optimization is possible by an implementation.
1:05:46
yitzi
The spec wasn't written like the w3 specs, as documentation of "existing practices," but as a comprimise by actual implementers, i.e. companies and researchers that had actual experience with the difficulties and issues associated with writing an efficient LISP implementation.
1:08:58
yitzi
The committee and the industry reps, in other words. It was very expensive to do at the time.
1:12:32
pillton
nij-: I think EVAL and COMPILE differ in their requirement to apply compiler macros so I don't think they would be the same.
1:13:45
pillton
Also, (compile nil (lambda () FORM)) is different to (compile nil '(lambda () FORM)).
1:15:10
nij-
But forming such a committee is quite expensive. There must be some main funders behind.
1:15:58
nij-
pillton The compiler macros are supposed to have the same effect of the corresponding function. So except this, the rest shoudl still be the same?
1:20:04
pillton
It depends on your definition of same. A compiler macro may cache a value in the global environment for example. The cached value may have no effect on the result of the form, but the environment is certainly impacted.
1:26:30
pillton
I would see the most differences between the interpreter and compiler in CMUCL. I know SBCL has an interpreter but I don't know enough to know when it is used in preference to the compiler.
3:04:06
beach
pillton: I have a use case for it. As part of the SICL bootstrapping procedure, I generate code that can be quite large, even from relatively modest source code. Compiling it takes a lot of time, and it is going to be executed only once. I found that the interpreter performs much better than COMPILE+FUNCALL.
3:05:49
beach
nij-: People worked for companies and universities, and they would provide the time for the members to participate in the committee.
3:10:54
beach
pillton: Yeah, in fact, COMPILE probably triggers some quadratic behavior in the compiler, so it is not just a minor advantage to use the interpreter. The compiler is so slow that it is unusable.
3:11:59
beach
Though, at some point I should apply some optimizations to decrease the size of the generated code.
3:13:28
pillton
beach: Regarding my comment about CMUCL: I meant encountering the differences in the process of evaluation rather than the performance of the evaluation. Remember seeing compiler macros not being expanded in some situations when they were on other implementations.
3:15:58
pillton
It was awesome from a personal development point of view. I had to re-read bits of the standard to understand where I got the wrong understanding.
3:18:04
pillton
On a completely different matter. I meant to raise the short form of DEFSETF. I don't think the standard specifies what the short form should do for the form which evaluates to the value to be assigned to the place.
3:18:28
beach
Creating a Common Lisp implementation is another way of forcing a thorough read of the standard. :)
3:20:29
beach
Of course, reading the standard also makes one discover the way too many cases of undefined behavior, hence WSCL.
3:21:12
pillton
Yeah, which is why I raised the short form issue of DEFSETF. I thought it might want to be added WSCL.
3:21:51
beach
You can write a short GitHub "issue" for it, and someone will have a look and write it up later.
3:22:08
aeth
the most underspecified part is apparently conditions, or, rather, which conditions are signaled
3:22:52
beach
aeth: But those are not the most serious ones. The most serious ones are all the cases where it is undefined behavior if you pass an object of the wrong type.
3:27:15
beach
Absolutely, and the WSCL issue suggests signaling a type error then. I believe every major implementation does that.
3:37:43
nij-
By the way.. should it be an WCSL issue that whenever an undefined behavior is hit, at least a harmless warning should be emit?
3:39:22
beach
I think that depends on the situation. If the implementation has to test some object type anyway, it might as well signal an error in safe code.
3:40:56
beach
nij-: The thing is, though, that WSCL is not trying to impose much new stuff. It is mainly documenting existing behavior.
3:43:32
beach
In the case of wrong object type, some implementations signal a simple error, and the WSCL issue might suggest a TYPE-ERROR, but that's a minor change for the maintainers.
3:49:01
nij-
Right. I think it's better to delegate this task to the ANSI tester. Ideally, it should test the undefined behavior and see how an implementation behaves.
3:49:45
nij-
Besides strenghening the standard (e.g. wscl), I think it's also very important to improve the test suite, and cross reference parts between it and the standard.
3:52:12
beach
I suspect the goal of the ANSI test suite is to just report non-conforming behavior, so it would be hard then to test undefined behavior.
3:54:38
nij-
How does other lang afford having an updated standard every now and then? To fully immerse oneself into one single standard is hard enough..
3:55:37
beach
They have no choice. Since they don't require the compiler to be present at run time and they have no macros, the only way to improve the language is to modify the standard.
3:57:13
nij-
Also, how does requiring the compiler to be present at run time helps stablizing a standard?
3:57:53
beach
But partly the same. The original standard did not require the compiler to be present, and they probably didn't have macros either. Originally, Scheme was designed to be a small language, but then ambitions increased.
3:58:57
beach
With the compiler present, you can get good performance of new operators defined by user macros if you define those operators right.
4:02:32
beach
Oh, also compile-time evaluation. Think of C++ templates. They are basically special-purpose macros that require a compile-time evaluation.
4:03:14
nij-
I never understand templates. But I think they have merits too? You can check more stuff at compile-time?
4:03:53
beach
They have merits, sure. But the way they are implemented is a mess because of the restrictions on the language (no macros, no compile-time evaluation).
4:31:35
pillton
C++ templates have a restricted form of evaluation though. You can't for example open a file or print a message to the terminal during the expansion of the template without implementing that support in the compiler.
10:50:32
scymtym
by now, c++ has real compile-time evaluation for a (growing) subset of the language in addition to templates: https://en.cppreference.com/w/cpp/language/constexpr
11:21:08
younder
C++ also has ambitions to throw away C headers. In 2026 the language might have lambda's ready for generic thread execution. Kinda the same we has had in Lisp with lparelell since 2015 or so.
12:27:34
jiny
in emacs slime debug how can I continue with different value that caused an error? I see it in bactrace 0: ..
12:30:31
beach
... and it is not related to SLIME. It is what the author of the code chose to signal.
12:31:48
decweb
If you're the author of the code, there are some convenenience forms like `check-type` which will signal restartable conditions, and might at least introduce you to the topic and you can look at its code.
12:33:01
beach
jiny: If you replace your BREAK by a CHECK-TYPE as decweb suggests, then you can alter the value in the debugger.
12:35:29
beach
jiny: And notice that the type given to check-type can be very specific, e.g., (NOT (EQL 234)).
12:38:24
jiny
thank you. i'm looking into https://www.lispworks.com/documentation/HyperSpec/Body/m_check_.htm that sounds like far beyond my level.
12:39:41
beach
jiny: It is not hard. If you have a variable FOO that takes on the value 234 and you don't want that, instead of (BREAK), write (CHECK-TYPE FOO (NOT (EQL 234)))