Opportunistic Mutation in Roc
roc-lang.org·17h·
Discuss: Hacker News
Flag this post

Roc is designed to have a small number of simple language primitives. This goal leads Roc to be a single-paradigm functional language, while its performance goals lead to some design choices that are uncommon in functional languages.

Opportunistic mutation

All Roc values are semantically immutable, but may be opportunistically mutated behind the scenes when it would improve performance (without affecting the program’s behavior). For example:

colors
|> Set.insert "Purple"
|> Set.insert "Orange"
|> Set.insert "Blue"

The Set.insert function takes a Set and returns a Set with the given value inserted. It m…

Similar Posts

Loading similar posts...