Functionally Equivalent Language Translation →
(mvar var-name) ; public member variable is the default (mvar+ var-name) ; public member variable (mvar# var-name) ; protected variable (mvar- (var-name default-value)) ; private member variable (mvar var-name-1 ; multiple CVAR-s will all have the var-name-2 ; same level of access control (var-name-3 "default"))
You should only use MVAR
within a current CLASS
declaration as it makes no sense to use it anywhere else. You can define a member variable with or without a default value or you can define many variables at once, again with or without a default value.
FELT supports the notion of member variables that can be "public", "private" or "protected" and in order to express those intentions you can choose from the following:
Instruction | Visibility |
---|---|
MVAR |
public |
MVAR+ |
public |
MVAR- |
private |
MVAR# |
protected |
For full details on how to compose a "class", read the CLASS page as that goes into some detail on how to declares classes in general. This page is more concerned with the actual means of declaring member variables.
To define a member variable you just name the variable within the MVAR
instruction like so:
(class Foo (mvar bar))
If you want to supply a default value then you use the same syntax as for when you write a function signature with DEFUN/FUNCTION, by placing the variable name and the default value inside parentheses like so:
(class Foo (mvar (bar 100)))
Instead of having to laboriously type MVAR
for every single class variable, you can in fact supply multiple of them at once like this:
and the FELT process will generate as much target code as is required to make them work for the chosen back-end language.