@@ -31,13 +31,8 @@ and contain many great points, I recommend reading them directly! In this
31
31
post, I'll try to summarize some common themes or topics that I thought were
32
32
particularly interesting.
33
33
34
- Several guides (such as Flix and Flow) point out a 80/20 rule: 80% of the times an error message is
35
- read, the developer knows that message well and knows exactly what to do. For
36
- this use case it's important that the message is short. On the other hand, 20%
37
- of the times this same message will have to be understood by a developer who
38
- has never seen it before and is confused, and so the message needs to contain
39
- enough information
40
- to allow them to find out what is going on.
34
+ Language Use
35
+ ------------
41
36
42
37
Almost all guides stress the need for plain and simple English, as well as
43
38
conciseness and clarity [Flix, Racket, Rust, Flow]. Flow suggests to put coding
@@ -53,6 +48,17 @@ Flow suggests to avoid "compiler speak". For example terms like 'token' and
53
48
be used (eg "name" is better). The Racket guide goes further and has a list of
54
49
allowed technical terms and some prohibited terms.
55
50
51
+ Structure
52
+ ---------
53
+
54
+ Several guides (such as Flix and Flow) point out a 80/20 rule: 80% of the times an error message is
55
+ read, the developer knows that message well and knows exactly what to do. For
56
+ this use case it's important that the message is short. On the other hand, 20%
57
+ of the times this same message will have to be understood by a developer who
58
+ has never seen it before and is confused, and so the message needs to contain
59
+ enough information
60
+ to allow them to find out what is going on.
61
+
56
62
The Racket guide proposes to use the following general structure for errors:
57
63
'State the constraint that was violated ("expected a"), followed by what was
58
64
found instead.'
@@ -65,6 +71,9 @@ suggestions altogether because "Students will follow well‐meaning‐but‐wron
65
71
advice uncritically, if only because they have no reason to doubt the
66
72
authoritative voice of the tool."
67
73
74
+ Formatting and Source Positions
75
+ -------------------------------
76
+
68
77
The Rust guide suggests to put all identifiers into backticks, Flow formats the error messages using full Markdown.
69
78
70
79
The Clang, Flow and Rust guides point out the importance of using precise
@@ -73,13 +82,17 @@ compiler information is used in the context of an IDE to show a red squiggly
73
82
underline or some other highlighting. The spans should be as small as possible to point out the source of
74
83
the error [Flow].
75
84
85
+ Conclusion
86
+ ----------
87
+
76
88
I am quite impressed how advanced and well-thought out the approaches are. I wonder whether it would makes sense for
77
89
Python to adopt a (probably minimal, to get started) subset of these ideas as guidelines for its own errors.
78
90
79
91
.. _`full list`:
80
92
81
93
Sources
82
94
-------
95
+
83
96
* Rust: https://rustc-dev-guide.rust-lang.org/diagnostics.html
84
97
85
98
* Clang: https://clang.llvm.org/diagnostics.html
0 commit comments