News for hackers. Stuff that matters.
Re:Nim v2.0 Released by frou_dh on Tuesday August 01, 2023 @10:56AM (#36956764)
Seems like it kinda has Sum Types, so Nim passes the litmus test for a respectable static type-system in this day and age.

https://nim-lang.org/docs/manual.html#types-object-variants

Re:Nim v2.0 Released by jackmott42 on Tuesday August 01, 2023 @12:14PM (#36958036)
I feel the same way as you! I've seen many language ideas come and go in my career and sum types are one I feel now should be a basic requirement. I miss them in any language without them.
Re:Nim v2.0 Released by c-cube on Tuesday August 01, 2023 @12:45PM (#36958558)
When I looked at it a few years ago, the compiler didn't prevent you from accessing fields from the wrong variant, and didn't provide exhaustivity checks. So I think it still falls short of this (excellent) litmus test :/
Re:Nim v2.0 Released by cobby on Tuesday August 01, 2023 @01:02PM (#36958830)
Also Nim requires you to use unique field names across all variants.
Re:Nim v2.0 Released by alwaysbeconsing on Tuesday August 01, 2023 @02:24PM (#36960205)
This annoying restriction is lifted in Nim 2; see the linked announcement.
Re:Nim v2.0 Released by xigoi on Tuesday August 01, 2023 @02:51PM (#36960627)
Where in the announcement does it say that?
Re:Nim v2.0 Released by ElegantBeef on Tuesday August 01, 2023 @03:06PM (#36960927)
They likely read "overloadable enums" and went "Oh Rust calls their tagged unions enums" so assumed all languages did.
Re:Nim v2.0 Released by alwaysbeconsing on Tuesday August 01, 2023 @06:07PM (#36963834)
Oh, no, I actually misunderstood cobby's complaint: the field names, yes, those still have to be unique. Which is also a bit annoying, though I've seen discussions about changing it.
Re:Nim v2.0 Released by elcritch on Tuesday August 01, 2023 @02:06PM (#36959903)
They've improved the compiler analysis for them significantly, including exhaustivity checks and field checks.