Changes between Version 3 and Version 4 of Sysel/Ideas

2011-03-28T19:38:49Z (13 years ago)
Jiri Svoboda

Elaborate on built-in relational types


  • Sysel/Ideas

    v3 v4  
    139139Semantically equivalent to additional return values of a function. A convenient way to return multiple values (especially since Sysel does not have tuples).
    141 === Built-in associative arrays ===
     141=== Built-in maps/sets/relations ===
    143 Maps and sets are so commonly used and so immensely useful that it might be worth incorporating into the langauge core. This could bring greater ease of use and optimization opportunities. This feature is present in D, for example.
     143Maps, sets and relations are very useful constructs (similar to their set-theory equivalents). Without such types relating two sets of objects means putting links in the objects themselves for each relation the objects participates in (similar to HelenOS ADT's `link_t`), which can be highly inconvenient.
     145Without support in the language core these can be difficult to implement. In C#, for example, they are based on a (library-implementable) hash table and rely on a hash function. This is not a very good design. Providing a stable (for the life of a process) hash function based on object identity is problematic. It cannot be based on object address since that would prohibit a moving garbage collector. Mono generates a hash upon object allocation and stores it along with the object. This, obviously, leads to wasting memory.
     147With maps, sets or relations in the language core, on the contrary, identity can be established solely upon relationships between the objects. No stable hashes are needed. The moving GC is not a problem because when moving an object it makes sure that all references to that object are updated.
     149This feature is present in D language core, for example.