Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass by name and pass by value-result languages

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.

like image 404
dancavallaro Avatar asked Apr 05 '09 00:04

dancavallaro


People also ask

What languages use pass by value result?

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.

What is the difference between pass by reference and pass by value result?

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.

Is Java a pass by value or pass by reference language?

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.

Is pass by name the same as pass by reference?

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.


2 Answers

The wikipedia article on evaluation strategy suggests that call-by-value-result is supported by fortran. Call-by-name is supported by algol 68.

like image 159
1800 INFORMATION Avatar answered Sep 22 '22 18:09

1800 INFORMATION


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!).

like image 38
Steve Avatar answered Sep 22 '22 18:09

Steve