Comp Language Struct
An ongoing series of my thoughts and ideas for my Comp programming language. Comp provides a single container type. It's a flexible container that combines both ordered and named fields in a unique...

Source: DEV Community
An ongoing series of my thoughts and ideas for my Comp programming language. Comp provides a single container type. It's a flexible container that combines both ordered and named fields in a unique style. A struct literal is defined by a series of fields in side of curly braces. Named and unnamed fields can be mixed freely, while always remaining ordered. Field values can be mixed and matched with any types. All data in Comp is immutable, including these structures. One way to think of this is similar to how Python arguments are defined for a function. Some arguments are positional and some arguments are named. When combined with Comp's shape values we get defaults and flexible morphing (casts). This makes Comp's structs work like Python arguments, but you don't need to invoke a function to assemble them. Some examples likely make this clearer. {"cat" 12+12 true} {name="Joe" score=14.5} {warning message="it did not work" timestamp=now} { {"car" year = 2021} {"bike" year = 2025} } Remem