Readit News logoReadit News
gingerBill commented on Context: Odin’s Most Misunderstood Feature   gingerbill.org/article/20... · Posted by u/davikr
travisa · a day ago
The linked documentation in the first paragraph is confusing. It sets things in `context`, then calls `supertramp()`, which doesn't even use `context.user_index` or `my_custom_allocator()` specifically, which is not defined in the example? Are we to assume that `new()` somehow makes use of `context.allocator` and `context.user_index`? It goes on to explain that new(x) is also `new(x, context.allocator)`, but never explains the relevance of `context.user_index` No wonder people "misunderstand"
gingerBill · a day ago
The code example is more to show the scoped copy-on-write behaviour of `context` more than how it is used in practice. I agree it might be a bit confusing and thus needs to be made clearer that is what the code example is meant to show. However, I don't there is any code example that could show "correct usage" of `context` without it defeating the point of it. As I say in the article, it makes more sense to leave it "confusing" because then people will ignore it.

The Overview is just that, an "Overview" and it's not meant be either a spec, a heavily detailed tutorial, nor an explanation of why a language construct is designed the way it is and/or why it exists. The latter of which would probably be as long as the Overview for each construct that exists if that.

gingerBill commented on Context: Odin’s Most Misunderstood Feature   gingerbill.org/article/20... · Posted by u/davikr
dustbunny · a day ago
Seems totally pointless to throw his own community under the bus with the initial paragraph. The first paragraph serves no purpose other than illuminate that ginger bill didn't want to write this, and is only writing it because we are too stupid to read his documentation.
gingerBill · a day ago
There is sadly a habit which is not bound to any "community", and I've seen a lot of cases where people will just rant a lot about something they don't understand when that rant could have been easily prevented by either reading the documentation/manual or asking someone in the first place. In the case of Odin, this is usually reading the Overview, the FAQ, or even just asking a question politely on the Discord/Forum/email. The implicit `context` system is one of those specific cases which is more likely to bring up an "uninformed rant". A lot of people seem to think you can figure everything out without reading a manual or rely on the veracity of what an LLM produces, and sadly this is not going to work for a lot of things in life. Most of the cases for explaining the existence of `context` (the thing the rant usually happens about) is usually solved by copying and pasting the two paragraphs from the Overview, explaining that it is for third-party interception. Sometimes it requires a longer explanation and thus I resorted to writing this article.

I don't like writing articles in general, since I am not a very good writer either, which is why I didn't want to write it; not because of the topic in itself. I could rephrase that first sentence/paragraph to not sound as "harsh" but when working on an open project, I would like people to at least read some form of documentation or just ask a question directly before they complain/rant.

gingerBill commented on Context: Odin's Most Misunderstood Feature   gingerbill.org/article/20... · Posted by u/enz
gingerBill · 2 days ago
I am the author of the article. If you have any questions, please feel free to ask :)
gingerBill commented on Titania Programming Language   github.com/gingerBill/tit... · Posted by u/MaximilianEmel
Lerc · 3 months ago
I'm aware that it lets you do things in a single pass manner, but this is the instance where I think the cost for allowing that is too great.

I always thought there must be a better solution, like emitting the compiled function body first which just increments the offset whenever a space for a variable is required and emit the function entry after the function exit last, so you can set up the stack frame with full knowledge of it's use. Then the entry can jump to the body. Scoping to blocks would let you decrement the offset upon exiting the block which would result in less stack use which would almost always be more beneficial than the cost of the additional jump.

gingerBill · 3 months ago
If you want single pass, then you have to do it on a per block basis at the most (e.g. C89).

But this is not meant to be a fully fledged language, it's meant to be a teaching tool. If you want a fully fledged language that allows for out of order declarations, try Odin!

Also, the syntax of Oberon/Pascal doesn't really allow for it in a nice way. It kind of looks really weird when you allow for it out of order.

gingerBill commented on Titania Programming Language   github.com/gingerBill/tit... · Posted by u/MaximilianEmel
cxr · 3 months ago
I'm referring to the semicolon insertion described in the README as, "When a newline is seen after the following token kind, a semicolon is inserted".

> Procedures don't even return things

Oberon allows return values from functions (which are still declared with the PROCEDURE keyword). It looks like the same is true in Titania:

    proc_body = decl_sequence ["begin" stmt_sequence] ["return" expr] "end".
<https://github.com/gingerBill/titania/blob/085b7b5bcf7f06076...>

I'm curious what you're going to do with the code generator. Parsers are easy and can be completed in a day or two. Even with a reference implementation, however, it's the backend that's a slog.

gingerBill · 3 months ago
I know Oberon does return things from certain procedures but I might not. I know the grammar allows for it but again, this is subject to change.

As for code generation, direct machine code to a Windows AMD64 PE executable.

Backend should not be that difficult because I am not working on anything complex nor optimizing. This won't be an optimizing compiler backend course.

gingerBill commented on Titania Programming Language   github.com/gingerBill/tit... · Posted by u/MaximilianEmel
cxr · 3 months ago
Trying to eliminate semicolons by doing JS-style ASI is gross and complicates things unnecessarily. You can trivially change the parser/grammar so that the semicolons in import, var, procedure, etc. declarations just aren't required, and likewise with statements that end in "end". They'll still be necessary for statements comprising things like assignments and procedure calls, but for a teaching language who cares.

(Your grammar is missing a definition for proc_call, by the way.)

gingerBill · 3 months ago
I only added that a few minutes ago, and it's a question of whether I should or not. This project is so goddamn new that I have not even decided anything. I was not expecting anyone posting this to HackerNews in the slightest.

Also this isn't JS-style ASI technically speaking, and it won't have any of the problems either. The syntax for this language is different enough that it won't be a problem. Procedures don't even return things.

gingerBill commented on Titania Programming Language   github.com/gingerBill/tit... · Posted by u/MaximilianEmel
troupo · 3 months ago
Wirth was obsessed with the idea of creating the absolutely minimal useful language, and many of his languages' warts come from that.

Variables are at the top because:

- you immediately see them (so, perhaps, easier to reason about a function? I dunno)

- the compiler is significantly simplified (all of Wirths' languages compile superfast and, if I'm not mistaken, all are single-pass compilers)

However, I feel that Wirth was overly dogmatic on his approaches. And "variables must always be at the top" is one of those.

gingerBill · 3 months ago
This has nothing to do with "dogma" and something simpler. It has nothing to do with "immediately see them".

Hint: This about this from a single pass compiler basis and how much memory needs to be reserved from the procedure's stack frame.

gingerBill commented on Titania Programming Language   github.com/gingerBill/tit... · Posted by u/MaximilianEmel
elcapitan · 3 months ago
@gingerBill Will there be accompanying blog posts or streams while you're building this?
gingerBill · 3 months ago
That was the idea.
gingerBill commented on Titania Programming Language   github.com/gingerBill/tit... · Posted by u/MaximilianEmel
Rochus · 3 months ago
Supporting lowercase keywords and making (at least some) semicolons optional already makes Oberon much more attractive ;-)
gingerBill · 3 months ago
And removing unnecessary keywords and modernizing it too. `[N]T` for arrays and `^T` for pointers, rather than `array N of T` and `pointer of T`. And supporting C++ style code `/*/` and `//`.

And as I develop this, I'll tweak it more so that people can actually understand without having to know the full histories of Pascals or Oberons or whatever.

gingerBill commented on Titania Programming Language   github.com/gingerBill/tit... · Posted by u/MaximilianEmel
smartmic · 3 months ago
Is the language/project somehow related to Odin or its ecosystem, or is it completely independent?

If the latter, I wonder how you can manage another programming language alongside Odin — anyway, thank you and great respect for both!

gingerBill · 3 months ago
Completely independent of Odin (except being written in Odin). It's a plan to be a teaching tool to learn compiler development, that's it.

u/gingerBill

KarmaCake day858March 31, 2014View Original