Ratstail91 / Toy

The Toy Programming Language.
https://toylang.com/
zlib License
231 stars 11 forks source link

Embed identifier types within strings? #130

Closed Ratstail91 closed 1 month ago

Ratstail91 commented 1 month ago

https://github.com/Ratstail91/Toy/blob/71c065a6c4dd7356823457db44186021aed10a95/source/toy_string.h#L15

If I changed this padding to Toy_ValueType, I could use it as the type of variable identifiers. It's not the prettiest solution, but the alternatives include copy/pasted code, or obtuse abstract hashtables.

I could even add a new string type, TOY_STRING_IDENTIFIER, which would block any attempts to fiddle with it like a normal string.

Ratstail91 commented 1 month ago

An alternative would be to store a string's hash.

Ratstail91 commented 1 month ago

I'll make a separate "string type" for identifiers that doesn't play well with the normal types, and can't be inserted into trees.

Ratstail91 commented 1 month ago

d62ee2a9a37ba16d64ebeb743ea38cadbd61c571

Added name type.