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.
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!).
The wikipedia article on evaluation strategy suggests that call-by-value-result is supported by fortran. Call-by-name is supported by algol 68.
if you pass a variable to a fortran function and you modify it there, you also modify it in the calling program:
psuedocode:
int j = 1
print j
addOne(j)
print j
would output:
1
2
Both Java and C are pass-by-value language.
C is clearly a pass by value language.
Java is always been told "primitives are passed by value, objects are passed by reference". But since java object is a reference at anytime, so it is actually a reference value.
Java Language specification tells this: http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#37472
Algol supports pass-by-name as you can find some explanation here
I was told that Ada supports pass-by-value/result but haven't tried out yet.
need difference between pass by value result and pass by reference......