The language suggestion states that the advantages are detailed in the linked paper. I had a quick skim through and I can't see it spelled out explicitly.
Is the advantage just that each statement gets executed in parallel so I might get a speed boost?
Or is there some kind of logic it caters for, that is not convenient using the usual monadic let!
?
I understand that, this being applicative, means that it comes with the limitation that I can't use previous expressions to determine the logic of subsequent expressions. So does that mean the trade off is flexibility for efficiency?
The LET function assigns names to calculation results. This allows storing intermediate calculations, values, or defining names inside a formula. These names only apply within the scope of the LET function. Similar to variables in programming, LET is accomplished through Excel's native formula syntax.
Use the LET statement to assign the value of expression to variable. See assignment statements for more information about assigning values to variables.
The Excel LET function lets you define named variables in a formula. There are two primary reasons you might want to do this: (1) to improve performance by eliminating redundant calculations and (2) to make more complex formulas easier to read and write. name1 - First name to assign. Must begin with a letter.
`const` is a signal that the identifier won't be reassigned. `let` is a signal that the variable may be reassigned, such as a counter in a loop, or a value swap in an algorithm. It also signals that the variable will be used only in the block it's defined in, which is not always the entire containing function.
The way I understood Don Syme's description, when I read it a while ago, was every step in the let! ... and! ...
chain will be executed, unlike when you use let! ... let! ...
. Say, for instance, that you use the option
CE. Then if you write
option {
let! a = parseInt("a")
let! b = parseInt("b")
return a + b
}
only the first let!
will be executed, as the CE short-circuits as soon as it meets a None. Writing instead let! a ... and! b = ...
will try to parse both strings; though not necessarily in parallel, as I understand it.
I see a huge benefit in this, when parsing data from external sources. Consider for instance running
parse {
let! name = tryParse<Name>("John Doe")
and! email = tryParse<EMail>("johndoe@")
and! age = tryParse<uint>("abc")
return (name, email, age)
}
and getting an Error(["'johndoe@' isn't a valid e-mail"; "'abc' isn't a valid uint"])
in return, instead of only the first of the errors. That's pretty neat to me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With