Kartik Agaram
Stefan
06/08/2020, 1:16 PMKartik Agaram
This is *emphasized
# text.* Or is it?
Things are simpler if I require headings to always start a new paragraph.
---
I came up with the algorithm myself, but it felt like a fairly straightforward multi-pass compiler design. The only minor issue was the chicken-and-egg problem of needing sizes to compute field offsets, and needing field offsets to compute sizes. I'm not well-versed with the theory of Algorithms so I can't cite good keywords here. But I think a lot of people would be able to come up with it after completing a grad course in compilers. Once the problem was framed.Stefan
06/08/2020, 3:59 PMIvan Reese
Ivan Reese
Kartik Agaram
method_missing
(did I understand "error handling" right?) or open types. It's fairly unambitious as a language; all the attention has gone to bootstrapping the implementation out of machine code.
But your concrete question is quite acute. "What happens if you've used a field that doesn't appear in the type definition?" I hadn't thought of it yet when I made the video. It only occurred to me in the past week. I now raise an error if a type definition failed to reconcile some field from earlier. But it's a fairly klunky error message; it just says, "you used field x
but it doesn't exist." It can't give the line or even function that used x
. Providing such errors is going to complicate the implementation quite a bit, needing to attach source info to uses of fields in types. But I did stake out a position in my paper as being all about the quality of error messages. This whole thing is now making me quite unhappy. Perhaps I'll toss out this flexibility after all.
Funny story: the previous prototype of Mu (a tree-walking interpreter) did have support for literate programming. (And function overloading, and generics, none of which are in the current prototype.) I hadn't connected the dots to think of this as a particularly Literate feature. That might be a good justification to take it out. Thanks!
_The reason Mu doesn't have LP anymore_: I was fine encouraging hunks to refer to local variables that were in the same scope but far away in some other part of the description. However, the way Mu now exposes and requires using registers, hunks can now destroy local variables far away in the same scope (that happen to share the same register). That feels too mind-bending.
Then again, maybe I should allow shadowing. So you can't insert naked statements using Literate directives, only blocks. Hmm, that could work. (If I can get the error messages good enough.) Thanks!Kartik Agaram
Ivan Reese
I hadn't connected the dots to think of this as a particularly Literate feature. That might be a good justification to take it out. Thanks!You troll!
Reader, please let the author know what you think of this precious-snowflake navel-gazing.I think you have some tough decisions ahead of you.
Then again, maybe I should allow shadowing.Is Mu aimed at beginners? If so, be careful about shadowing. In my experience every new programmer steps on that nail, and I've known some who were then scared away from taking advantage of it for evermore. (Example of the nail: top-level variables can be shadowed, struct members can't, but you often assign to both in the same way.)
Perhaps a low-level language built in machine code should throw up its hands and require the programmer to do a little more work.That could be a worthwhile bunt for the time being, and you could come back to this in the future.
Kartik Agaram
Kartik Agaram
Ivan Reese
top level
a = 5
b = a
a = 6
wtf is b?
struct
a = {x: 5}
b = a
a.x = 6
wft is b?
shadowing
a = 5
{
a = 6
}
wtf is a?
Kartik Agaram
Kartik Agaram
Ivan Reese
Kartik Agaram