views:

1574

answers:

7

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.

+1  A: 

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

Steve Haigh
I'm not sure C macros "count" for what I'm trying to do, but that's an interesting thought, so thanks for that.
dancavallaro
+4  A: 

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

1800 INFORMATION
Thanks, I think I'm going to go this route.
dancavallaro
**Algol 60** has call-by-value and call-by-name; **Algol 68** has call-by-value and call-by-reference, and the programmer can manually adopt a call-by-copy-restore methodology. Call-by-sharing looks a bit like call-by-reference (in the form of "proceduring"), but I'm not sure if they are actually the same in Algol68. The first version of Algol68 had call-by-need, but it was removed in Rev1;
NevilleDNZ
+1  A: 

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
masher
I was always amused by the (really) old versions of Fortran that would let you call addOne(1) and modify the value of the constant 1.
Greg Hewgill
A: 

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

arsane
This is true, but doesn't answer my question..
dancavallaro
+1  A: 

I think CLIPS expert system language would be pass by name.

AaronLS
A: 

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.

phamnamlong
A: 

need difference between pass by value result and pass by reference......

Rakesh