For my programming languages course, I'm trying to write some code snippets in languages that use pass by name or pass by value-result, preferably by default, but any language that even supports either of those would be fine. However, I haven't been able to find a single language that supports either of them. Does anyone know of a language that uses pass by value-result or pass by name? Preferably an imperative language.
The most common are pass-by-value and pass-by-reference. C++ supports both techniques, while most other languages (Java, JavaScript, Python, etc.) use pass-by-value exclusively.
The main difference between pass by value and pass by reference is that, in a pass by value, the parameter value copies to another variable while, in a pass by reference, the actual parameter passes to the function.
Java is officially always pass-by-value. The question is, then, “what is passed by value?” As we have said in class, the actual “value” of any variable on the stack is the actual value for primitive types (int, float, double, etc) or the reference for reference types.
In this sense the evaluation method is similar to pass-by-reference. The difference is that since with pass-by-name the parameter is evaluated inside the function, a parameter such as a[i] depends on the current value of i inside the function, rather than referring to the value at a[i] before the function was called.
The wikipedia article on evaluation strategy suggests that call-by-value-result is supported by fortran. Call-by-name is supported by algol 68.
I think C Macros are Pass-by-name (not the C language itself of course). I don't know of any pass-by-value-result languages I'm afraid (to be honest I had to do a web search to find out what it means!).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With