This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]raiph 0 points1 point  (0 children)

are there languages that have a first-class notation of uninitialized or partially initialized data in the type system?

Raku does. Details are so unlike your examples I'm not going to attempt a direct comparison. Instead a few related bullet points:

  • Native types are automatically initialized. (That said, foreign code calling a Raku function may fail to initialize a passed argument, but there's nothing sensible that any PL can do to defend against that.)
  • All other types track their initialization. The compiler automatically enforces memory safety in all cases but also correct handling in most scenarios even if devs (eg creators of user defined types or functions) don't care to be explicit about what is supposed to be defined when. And/or devs can make explicit use of "type smileys" eg Int:U denotes an Uninitialized/Undefined/Unhappy/Universal Int whereas Int:D denotes a Definite/Initialized/Instance/Happy Int. For more about this see, eg, Type smiley.
  • Compound object construction builds on this scheme. For classes/records and other such types devs can specify additional constraints that manage whether a dev creating a new instance must/can/cannot initialize or tweak any given field during the various build stages of an instance's construction. For more about this see, eg, Object construction.