The constness problem ===================== This applies to other qualifiers than just "var". But it mostly known for the const problems that happen in C-like languages: The "strchr"/"memchr" and similar functions take a const but return a non-const. That is of course not acceptable in a safe language. Solution 1 ---------- Allow functions to specify a "var" return and infer the var-ness based on the function arguments. For example: func ref ByteBuffer.subrange(int low, int high) -> var ByteBuffer func f() { ByteBuffer cb = ... var ByteBuffer vb = ... # In this case, the return type loses the var-ness # because there is no argument that is var ByteBuffer cb1 = cb.subrange(1, 3) # In this case, the return type retains the var-ness ByteBuffer vb1 = vb.subrange(1, 3) } (This syntax works because a function taking only non-var parameters cannot ever return a var value. So it would be meaningless, and can be given this alternate meaning.) Problem: How should/can this work with multiple parameters? # In this case, the function should base the var-ness on # the implicit "this" parameter. func ref ByteBuffer.largest_common_range(ref ByteBuffer other) -> var ByteBuffer How does this work with other qualifiers, such as "arena", "threaded"? - The parameter can only come from the input! - BOTH the input and output should have the qualifiers - The compiler should eliminate qualifiers on the output that are not present on the input. Solution 2 ---------- Allow functions to specify a "var" return and infer the var-ness based on a specific argument: func ref ByteBuffer.largest_common_range(ref ByteBuffer other) -> var(this) ByteBuffer How does this work with other qualifiers, such as "arena", "threaded"? Solution 3 ---------- Use a special keyword to inherit ALL qualifiers: func ref ByteBuffer.largest_common_range(ref ByteBuffer other) -> quals_of(this) ByteBuffer Regarding specific qualfiers ---------------------------- var, writeonly, arena, aliased, threaded: - No specific considerations own: - An "own" parameter can ONLY take "own" values, and non-"own" parameters can ONLY take non-"own" values. --> inference/inheritence of own-ness makes no sense. Regarding output parameters --------------------------- - Will NOT work fully with solution 1. - With solution 3: "var aliased(other_param) out_param" - With solution 3: "var quals_of(other_param) out_param" Related problem: - Qualifiers on nested references?