simple definition of "in" function parameters, and default "ref"

John Nixon john.h.nixon1 at gmail.com
Sat Oct 27 11:48:55 UTC 2018


I have just read that the storage class "in" for function 
parameters has not yet been properly implemented. From its simple 
meaning as a one-way flow of information into a function from the 
calling function, surely it should be implemented by copying the 
argument, as is now done by default for all function arguments. 
Note this has a distinct meaning from the far more restrictive 
"const" that enforces the variable to remain constant throughout 
its lifetime while the called function is running. It would then 
naturally complement "out" and provide a simple semantics in the 
function signature to aid program design.
It would also make it simpler if there was no difference between 
the behaviour of reference and value types in function parameters 
with default passing by reference. This would make the storage 
class "none" correspond to "in" and "out". At present if this is 
wanted, sometimes the keyword "ref" has to be used, and sometimes 
it is not necessary (depending on whether the type is value or 
reference).
A simplified language would make it easier to develop programs to 
check programmer's code.



More information about the Digitalmars-d mailing list