Cicada ---> Online Help Docs ---> Reference ---> Functions define in Cicada scripts

start.cicada

The start.cicada script provides an interactive command prompt, while keeping most of its internal functions hidden from the user. However, a few of its variables and functions have aliases inside the user’s workspace, and those are the focus of this section.


calculator:

is a function that prints the results of incomplete expressions at the command line. An incomplete expression is one that is not assigned to a variable, or used in any other way. For example, if the user types


    a = 5 + 2
   

then nothing will be printed, regardless of whether calculator is on or off. However, if the user were to enter just


    5 + 2
   

then the answer ‘7’ will be printed, thanks to the calculator.

To be completely technical, the calculator prints the data of all hidden members created by the user. Since these members will never be used again start.cicada removes them after each command from the user, but only after asking the calculator to print them first. The calculator is only a printing function, not a calculator per-se.

By default, the calculator is aliased to user.cicada’s sprint() function. We can change the output style by aliasing it to another printing function:


    > calculator = @mprint
   

Or, if calculator is getting annoying (e.g. printing the output of functions we don’t care about, or that return enormous blocks of data), we can turn it off altogether:


    > calculator = @nothing
   


ans:

: short for “answer”. This is aliased to whatever the calculator last printed (void if the calculator hasn’t printed anything yet). Use ans like any other variable:


    > 2+5
   
    7
   
    > ans*2
   
    14
   


allNames:

the list of member names that have been defined so far, including those defined in start.cicada. allNames is updated with every new command-line prompt, or every time the user calls compile() with allNames as the fourth argument. This list is used by user.cidada’s go() and what() functions.


go_path[]:

a set of aliases to each composite object in the search path, beginning with root and ending with the current working variable. start.cicada uses go_path to form the search path for each command entered by the user. Both go() and jump() work by modifying go_path, and start.cicada will reset go_path if it detects a problem. The user can add a small coding section to go_path which start.cicada will run if it needs to reset the path; in this coding section do not define any variables or run any functions or problems will start happening.


Prev: Functions define in Cicada scripts    Next: user.cicada


Last update: May 8, 2024