Coding 2023-11-30

Tags:
By Max Woerner Chase

I haven't really touched the languages I was talking about last time, but I have thought of something to attempt with them that should be more interesting than running through a couple of basic introductory exercises. I have a book, which documents some code, which I wish to adapt for purposes outside of its original design. I could try to work with the code in its original language, but I... don't want to. So, let's try working with it in those languages.

My plan is to try to express things in a marimo notebook for prototyping, and then try to transplant that design to the other languages. We'll see how that goes; when I was thinking about this earlier, I remembered running into Weird Problems because I was trying to customize Python's enum support in a very specific way that must not have been expected.

...

I tracked down the problem I ran into, and now this is just going to bother me. Basically, I was trying to make an Enum where the auto values start at 0 instead of 1, and the code has both:

...

Found it.

v.value = self._generate_next_value(
    key, 1, len(self._member_names), self._last_values[:],
    )

:) (glitchy)

Why does the staticmethod take an argument if it's always going to be a constant?

I'm not sure why the interface is like that, but now I hypothesize that the "hack" is almost the right version, and I should remove the "elegant fix", because it's subtly breaking one of the interfaces. I'll see what I think tomorrow.

Good night.