Variables

Comefrom0x10 has variables just like most other languages. It uses duck-typing, because ducks are delicious, when prepared just so, with a nice crispy skin, and does away with pesky declaration nonsense. Just assign to a variable to create it:

greeting = 'Hello'

Strictly speaking, assignment doesn’t create the variable. As with “hoisting” in JavaScript, names are in scope throughout the block. Before assignment, the name greeting exists, but with the value undefined.

In fact, it’s even simpler than that. It (usually) doesn’t matter whether a name is in scope. A Cf0x10 design principle is that your programs should never have fatal runtime errors, thus Cf0x10 programs, like shell scripts, are extremely robust against crashes. You are free to refer to a name that’s never assigned at all, if you wish, so this is a complete and valid Cf0x10 program, that just prints nothing at all:

greeting

Whereas, this program prints “Hello”:

greeting = 'Hello'
greeting

See Types in the documentation for specifics.

Later in this tutorial, we will see that assignment is closely related to control flow.