1
lorentz
9d

I made a very obvious realization since the last time I rewrote Orchid; the 3 year project that has now become an eloquent documentation of my learning process; Types aren't free. Sure they're free at runtime, in fact the more you have the less the language has to work to separate values, but they generate significant cognitive load.

Oftentimes it's better to have one enum with 12 variants 3 of which are specific to a narrow case to be able to define operations for this enum once, than it is to have 3 distinct enums of 10, 11 and 8 variants respectively, and to have to define common operations (or the dispatch part anyway) thrice.

As for my previous observations about catchall abort acting like the new type abort, I still think that, and I still think that this is only justifiable if the number of invalid variants is low enough in every case that you can list all of them before the abort.

Comments
  • 1
    Even still, I feel like defining a struct that's entirely local to a function that returns it and another that consumes it is better than any alternative. I'm not sure what makes a type expensive, I guess duties like representing a different type but with constraints?
  • 1
    I rewrote retoorscript many times too. Writing a language is a Rollercoaster. But damn, it's fun
  • 1
    @lorentz my language doesn't know line numbers. My lexer parses everything in between {}, (), [] as a string. The token type is curly brace for example and the content is the source. So my interpreter does lexing all the time. But tbh, my interpreter is the simplest I've seen out there.

    You can do really add_function(interpreter, "while", &while_fn).

    But I skipped garbage collection in this version. It's very hard to implement afterwards :(
  • 1
    @retoor Ah yes, the GNU Make architecture. Orchid started out that way, but I rely on the preprocessor being very very fast so from the day I had 200 token functions I needed at the very least a tokenizer that interns names.
Add Comment