I am wraping some SQL Stored Procs with in/out parameters. This of course means I have to do ugly stuff like declare my parameters as by reference and use mutables.
How would I do this in F#?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
F# does indeed have a
byrefparameter. Here’s an example from the MSDN page:Mutable variables also exist (though there’s an important difference between using
refandmutablevariables, either of which can be used for many of the same purposes). The MSDN page on this subject is very informative – including a discussion of when to use which keyword/construct.Example of reference variables:
Example of mutable variables:
As you can see, the syntax for assignment (as well as retrieval) differs between the two constructs, too.