Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass by Reference in Haskell?

Coming from a C# background, I would say that the ref keyword is very useful in certain situations where changes to a method parameter are desired to directly influence the passed value for value types of for setting a parameter to null.

Also, the out keyword can come in handy when returning a multitude of various logically unconnected values.

My question is: is it possible to pass a parameter to a function by reference in Haskell? If not, what is the direct alternative (if any)?

like image 267
MathuSum Mut Avatar asked Nov 29 '22 14:11

MathuSum Mut


1 Answers

There is no difference between "pass-by-value" and "pass-by-reference" in languages like Haskell and ML, because it's not possible to assign to a variable in these languages. It's not possible to have "changes to a method parameter" in the first place in influence any passed variable.

like image 94
newacct Avatar answered Dec 10 '22 13:12

newacct