A small example (Figure 1) may help give a feel for the Nickle language. Note that the variables i and t are declared at first use. The language feels much like C, but with some of the bothersome details of declaration and typing optional.
![]() |
This much code would typically be placed in a file, and
read into a running Nickle session (``>
'' is
the default Nickle prompt here and throughout)
> load "countsum.5c"During reading (which occurs with no perceptible delay) the input file is incrementally compiled into the running session. We can then interactively create a sample array to work with.
> v = [5]{1, 2, 3, 4, 5} 1 2 3 4 5The square brackets are the array constructor, and in this case create a dynamically-typed array of 5 elements. The curly braces, as in C, are being used to surround an initializer list which values the array elements
a[0] = 1
a[4] = 5
.
Now we can invoke
countsum()
(which is extracted from a Cribbage scoring
program).
> countsum(15, v, dim(v)) 1 > countsum(12, v, dim(v)) 2If a new definition is given interactively for
countsum()
,
it will scope out the current definition.
As expected, the storage for v is allocated automatically,
and released when v becomes unreachable.