dancavallaro
dancavallaro

Reputation: 13337

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.

Upvotes: 6

Views: 7266

Answers (6)

phamnamlong
phamnamlong

Reputation: 51

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.

Upvotes: 0

AaronLS
AaronLS

Reputation: 38394

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

Upvotes: 1

Sam Liao
Sam Liao

Reputation: 46113

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

Upvotes: 0

masher
masher

Reputation: 4116

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

Upvotes: 1

1800 INFORMATION
1800 INFORMATION

Reputation: 135413

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

Upvotes: 3

Steve
Steve

Reputation: 8511

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

Upvotes: 1

Related Questions