Skip to main content
  1. The pint° programming language/
  2. Language overview/

Let declarations

The let keyword allows you to declare names, both regular declartions and function declarations. All names declared with let are available in the top-level scope of the pint° program.

let declarations are always immutable, and thus cannot be redefined.

Regular let declarations #

A regular let declaration has the syntax let a = b, where a is a name and b a expression which evaluated value will be assigned to a. The declared identifiers can then be referred by other let declarations or in function calls.

Here are some examples:

1
2
let name = "Mateus Pinto"
let numberOfcatsHeHas = 1

Function let declarations #

By appending a parameter to a let declaration identifier, it is converted to a function let declaration.

1
let myFunction param = "returning a string"

pint° functions have always a single parameter1, and current implementation parameters are simply ignored, so you can’t use them. However, this code works and compiles to a parameterless function in Dart.

1
String myFunction() => 'returning a string';

Identifiers #

As we are talking about name declarations, this may be a good place to define what are valid or invalid identifiers in pint°.

For interoperability reasons, pint° chose to follow Dart’s identifier rules, so:

  • Identifiers can have all regular ASCII letters (no diacritics), numbers, _ and $.;
  • Identifiers can’t start with a number.

Thus, those are some example of valid identifiers:

  • myVariable
  • _privateVar
  • totalAmount
  • calculate$um
  • UserName
  • MAX_VALUE
  • isValid123

And some invalid identifiers:

  • 123start (cannot start with a digit)
  • my-var (hyphens are not allowed)
  • my/function (operators can’t be used)

  1. Multiple parameters will be handled in the future with tuple-like structures. ↩︎