-
Notifications
You must be signed in to change notification settings - Fork 2
The Make Statement
Whenever you want to declare a variable in the Q Programming Language, you will need to use the make
statement. This is a very simple statement if you want it to be, but when used in certain ways can become a very powerful and complex part of Q PL.
The syntax for a simple make
statement, for example one that creates a integer variable called myInt
would be written like the example below.
make integer myInt;
As you can see, this is very simple and easy to adopt in your code. However, if you wanted to create a new kind of make-able variable, such as allow people to create uint8
type variables, which would be eight-bit integer values, you would need to do something like shown below.
make template uint8;
However, this would not define anything about what the uint8
template is, and to do that you would need to use the set statement. Although that is beyond the scope of this page, for the purpose of documentation, the correct
makeand
setstatement combination to create a variable type
uint8` being an eight-bit integer is shown below.
make template uint8;
set uint8 = unsigned integer 8;
As you can see, creating new variable types is relatively simple and is an efficient way to manage the variables you use in your code and help define there purpose.
It is important to note that any variable types you define yourself are seen the same as there base type, integer
, array
or string
to the computer, but the compiler will treat them as how you define them to be - preventing you from storing 16 bit values in an eight bit datatype and other things like that.
Another important note is that although the make
statement is limited to being used only in the data
section of your code, it can actually also be used inside function blocks
to create function-wide variables that are not accessible outside the function.