~lattis/muon

Updating the object and string id type

Details
Message ID
<20210911220741.ndkh6lvdj3pmjy5r@hostomei>
DKIM signature
pass
Download raw message
I've been thinking for awhile that using uint32_t for everything
(numbers, object ids, string ids, ast nodes) can get confusing.  After
some consideration, I decided on typedefs over other solutions.  To that
end, I've introduced two new typedefs `obj` and `str` and started to
replace all instances of uint32_t.  Until I'm finished, the code might
be even more confusing unfortunately, which is why I thought an email
might be warranted.

Here is some additional information, copied from CONTRIBUTING.md:

> ## Objects, strings, and `uint32_t`
>
> All objects and strings are stored and passed by id, rather than pointer.  Until
> recently, all these ids were `uint32_t`s.  Since that hurts readability, and it
> is somewhat inconvenient to type, `obj` and `str` (both `uint32_t` typedefs)
> were introduced.  While these don't help with C type checking unfortunately,
> they do help document the code, and are also convenient to type.  Internally,
> these ids are tagged and a runtime assert should catch any mix-ups.
>
> Currently, the migration from `uint32_t` is in progress, so be aware that some
> code still refers to strings and objects that way.

Stone
Reply to thread Export thread (mbox)