Skip to main content
9 votes
Accepted

Prior art on modeling characters of variable lengths

Swift Swift’s Character type represents an extended grapheme cluster. As you mention in your question, this means a single ...
Alexis King's user avatar
  • 8,731
5 votes

Why do most languages prefer complex enum instead of simple enum?

I feel mainly two reasons: Structs corresponding to a single enum variant needs a name, while they have only one canonical use case, so it might be desirable to make these structs anonymous, hence ...
ice1000's user avatar
  • 2,454
5 votes

What are pros and cons of tagged vs untagged union-types?

Using untagged unions needs a lot of boilerplate to use safely and it's easy to mess up and cause undefined behavior A pure untagged union does no type checking so you can interpret it's contents as ...
mousetail's user avatar
  • 8,359
5 votes

What are pros and cons of tagged vs untagged union-types?

The pro is that you can save some memory (cache) when using them. If there are 2 fields that are never used together then you can put them into a union and only pay the size cost for the larger of the ...
ratchet freak's user avatar
3 votes

Why do most languages prefer complex enum instead of simple enum?

One advantage of "complex enums" over "simple enums" combined with separately defined structs is that not having the structure be a type in it's own right can enable more efficient ...
Peter Green's user avatar
3 votes

What are pros and cons of tagged vs untagged union-types?

It's a trade-off between safety and flexibility. By attaching a tag to every union, a language can prevent access as the wrong type. However, that prevents use for type-punning as is commonly ...
Toby Speight's user avatar
2 votes

What are pros and cons of tagged vs untagged union-types?

Some tasks require "polymorphic records". For instance, some simulation involving transport vehicles may need additional fields that differ for a light car, a truck, a motorbike, a light ...
Audrius Meškauskas's user avatar
1 vote

Challanges to integrate sum types into json/protobuffer/toml/yaml?

Depending on how easy it is to differentiate the types, you might be forced to make sum types tagged. For example, a type float | int would be impossible to infer ...
kouta-kun's user avatar
  • 1,359
1 vote

Prior art on modeling characters of variable lengths

It would certainly be possible to model a string purely as a list of variable length "character" values, e.g. using a linked list structure, or an array of fixed-sized references. However, ...
IMSoP's user avatar
  • 2,428
1 vote

Prior art on modeling characters of variable lengths

Two approaches that come to mind would be: Allow an immutable string type to hold an array of bytes, halfwords, or words, depending upon whether all code points are within the range 0..0x7F or 0.....
supercat's user avatar
  • 1,812
1 vote

Prior art on modeling characters of variable lengths

The main way this is done (with some variation) in modern programming languages is to have your String type store an array of bytes that have special indexing so ...
Oscar Smith's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible