Ask HN: Do we have a programming language with a permission system?
TLDR: Declare variables as `let some_var: rw i32` for a read-write i32.
I was looking into Val and Rust and we can see that they have different semantics for different things you can do with variables. In rust you can use &T to borrow (which is like read-only), &mut T to read-write and T to own. Val has similar semantics with let, inout, sink and set. However, some of them "encompass" others. For example, if I pass &mut T I can read and write to the variable, if I pass T I take full ownership and I can read write and own it. There is no such thing as "write-only" or "own-only" (correct me if I'm wrong).
So why not have a language that defines these as a permission based system? Let's stick with read write own as `r w o`.
Ex:
fn foo(x: r i32){
let a: w i32 = x; // passes
x = 42; // fails
}
// Take ownership, x cannot be used outside after this is called.
fn foo2(x: o i32){
let a: w i32 = x; // fails
x = 42; // fails
}
fn main(){
let x: rwo = 23;
foo(x);
foo2(x);
print(x); // fails because foo2 took ownership and dropped it.
}