Skip to content

On uniqueness and mutability  #6

@madmalik

Description

@madmalik

Rusts central idea is to disallow mutability and aliasing at the same time (a little bit simplified). I'd like to discuss if it'd be useful to infuse a similar concept into a dynamic language.

Why?

  • Shared mutable data is a source of bugs.
  • Unique values makes resource management easier. I don't want to close my file handles manually, thank you very much. ;)
  • It may be a key for easy interop with rust (move values from rust into the runtime and move them out later, or knowing that if the rust part holds references into the runtime heap they cannot be mutated)

How would that work?

  • the functional route: pervasive immutability and persistent data structures (like clojure, erlang etc.)
  • every reference has to be unique. Aliasing is impossible and values can only be moved or cloned (may have a big performance impact)
  • make values immutable as soon as they are shared and check that on runtime (for example with reference counting and allow mutation on reference counts of one)

I don't know if a scripting language is the right place for this concept, but it seems to be mostly unexplored beside pervasive immutability.

Side node: Stack based (or concatenative) languages lend them self quite naturally to this concept since all standard operations are moving and copying/aliasing is explicit. Here is a quite old but interesting article about that: Henry G. Baker: Linear Logic and Permutation Stacks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions