Skip to content
flaviut edited this page Oct 21, 2014 · 11 revisions

Callsite annotations on var parameters would decrease mistakes

Possibly. The problem here is that of perception. In many languages, heap allocation through pointers is the only method of having objects, and passing them to a function gives the freedom to modify them. In Nim, things can be allocated on the stack, and those things need to be treated in the same way as things on the heap.

proc foo(input: ref T) = ...
let a: ref T
foo(a)  # valid, this is Java-style
var b: T
foo(b)  # also valid and equivalent
Clone this wiki locally