[rust-dev] idea: access modifiers as part of function signature

Kobi Lurie kobi2187 at gmail.com
Sat Apr 7 06:36:05 PDT 2012

Thanks for the prompt answers :-)

What do you think of explicitly defining what a function can do with a 
certain argument?
I talk about adding keywords such as: ro (readonly), rw (readwrite), wo 
(writeonly), unused.
I think this can help in finding a bug, by shortening the "search space" 
- the argument was readonly so it wasn't changed here..
it's also less of a mental burden than thinking about pointers/references.
C# also has the 'out' modifier for writeonly.

this can make things more clear about permission/ownership.

(I know that when passing by value, this somewhat achieves readonly, as 
the value passed will not have effects beyond the function scope.)

The more fleshed out suggestion is that the compiler will force writing 
or removing these modifiers according to the function body.
I am not sure whether interfaces should include or not include these 
modifiers on the function signatures.

I have a few ideas, and the thought is perhaps a young language would be 
more open to consider them.

see you, Kobi

More information about the Rust-dev mailing list