Page last modified on July 05, 2014, at 07:49 AM

Causerie.Variables History

Hide minor edits - Show changes to output

Added lines 1-16:
As with other languages, causerie allows the programmer to define and use variables, which represent an item with a value that may change at runtime.  Unlike other languages, variables in causerie all take up exactly the same amount of space, since they represent instances of an existing class -- objects.

!!Defining Variables
Variables may be defined with the %incode%'''var'''%% keyword.  They may optionally be initialized with a value by calling the assignment method on the newly-minted variable:
(:source lang=causerie -getcode:)
// Define a simple variable
integer var myValue;

// Define and initialize a simple variable
float var pi := 3.14159;

// Define a variable which defaults to 'id'
var genericVariable;

As shown above, you may specify the name of the class which is used to create the instance to which each variable refers; this is roughly analogous to its type.  In the example above, both %incode%integer%% and %incode%float%% name types that are defined by the [[Runtime/|runtime library]].  If you omit the class, then the compiler assumes the variable is an uninitialized instance of %incode%'''id'''%% -- a generic pointer to an object.



recent changes

edit SideBar

All site content copyright © its various contributors.
Licensed under Creative Commons License