2020-05-15 13:41:26 +03:00
|
|
|
---
|
|
|
|
layout: developer-doc
|
|
|
|
title: Bindings
|
|
|
|
category: semantics
|
|
|
|
tags: [semantics, bindings]
|
|
|
|
order: 1
|
|
|
|
---
|
|
|
|
|
|
|
|
# Bindings
|
2020-07-21 15:59:40 +03:00
|
|
|
|
|
|
|
A "binding" is a portion of and Enso program that creates a new name and binds a
|
|
|
|
value to that name.
|
2020-05-15 13:41:26 +03:00
|
|
|
|
|
|
|
<!-- MarkdownTOC levels="2,3" autolink="true" -->
|
|
|
|
|
|
|
|
- [Binding Return Value](#binding-return-value)
|
|
|
|
|
|
|
|
<!-- /MarkdownTOC -->
|
|
|
|
|
|
|
|
## Binding Return Value
|
2020-07-21 15:59:40 +03:00
|
|
|
|
2020-05-15 13:41:26 +03:00
|
|
|
While some expression-based languages with bindings have the binding return the
|
|
|
|
value assigned to the binding, we feel that this is far too error prone.
|
|
|
|
Consider the following code as a demonstration:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
if x = someExprEvaluatingToBool then foo else bar
|
|
|
|
```
|
|
|
|
|
|
|
|
This is the perennially-discussed C++ bug where you fail to type `==` in an
|
|
|
|
if-statement.
|
|
|
|
|
|
|
|
Enso, instead, takes the approach where a binding expression returns the
|
|
|
|
singleton value of the type `Nothing`, making the above-written code a type
|
|
|
|
error.
|