I see these sentences on the book "functional programming in scala":
If the evaluation of an expression runs forever or throws an error instead of returning a definite value, we say that the expression does not terminate, or that it evaluates to bottom. A function f is strict if the expression f(x) evaluates to bottom for all x that evaluate to bottom.
Sorry for my poor English, I found myself can't understand this sentence well:
or that it evaluates to bottom
Two parts I can't understand:
Thanks
"Evaluates to bottom" is a way to say that an expression doesn't return normally: it throws an exception, gets stuck in a loop, or halts the program. The reason that phrase is used is because sometimes it's convenient to pretend that all expressions evaluate to a value. Once you pretend that non-returning expressions produce a value called bottom you can simplify your description of how expressions interact.
The bottom type (in Scala called Nothing) is related: it's the type of expressions that can only produce the bottom value (i.e. not terminate normally). In Scala the expression "throw new RuntimeException()" has the bottom type (Nothing), and in this terminology we would say it produces the bottom value.
These uses of the word "bottom" come originally from formal logic and then into programming via formal language semantics.
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