Val
https://gyazo.com/c17135ed8ed9bf1838962d56279c6a9b
mutable value semantics and generic programming for high-level systems programming
website
github
Swift実装
パフォーマンスを犠牲にすることなくvalue semanticsを扱う
例
code:val(rs)
subscript longer_of(_ a: inout String, _ b: inout String): String {
if b.count() > a.count() { yield &b } else { yield &a }
}
fun emphasize(_ z: inout String, strength: Int = 1) {
z.append(repeat_element("!", count: strength)))
}
public fun main() {
var (x, y) = ("Hi", "World")
emphasize(&longer_of&x, &y)
print("${x} ${y}") // "Hi World!"
}
&がついているのはmutableであることを意味する
(Rustのようにアドレスであることは意味しない)
@mootastic: プログラミング言語Val。すべての値が値型 (value type) であり、明示的なポインタ・参照をもたない。しかしmutable value semanticsという枠組みにより、関数(のようなもの)はin-placeで値を変更できる。文法はRust似。ネイティブにコンパイル可能。
https://t.co/N9N4qAO8rR
#プログラミング言語