News for hackers. Stuff that matters.
Re:Embedded Swift on the Raspberry Pi Pico by tialaramex on Wednesday March 06, 2024 @08:31AM (#39615745)
I have never seen this called a "union", and that's certainly not what people mean when they speak of a "tagged union".
Re:Embedded Swift on the Raspberry Pi Pico by bmitc on Wednesday March 06, 2024 @09:04AM (#39616059)
What do you think tagged unions are? What languages are you referring to?

F# calls these discriminated unions. OCaml calls them variants or tagged unions.

https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...

https://ocaml.org/docs/basic-data-types#variants

Re:Embedded Swift on the Raspberry Pi Pico by tialaramex on Thursday March 07, 2024 @04:30AM (#39626978)
Huh. I was thinking about this in much lower level terms, it seems weird to me to define these structures recursively when how they're actually stored is thus omitted yet that's actually crucial, but I guess if you work in a sufficiently high level system you don't care about the implementation details.
Re:Embedded Swift on the Raspberry Pi Pico by louthy on Wednesday March 06, 2024 @10:36AM (#39617044)
It is exactly what they are. ‘Tagged’ or ‘discriminated’ unions are a set of named product types - the name being the tag/discriminator.