F.E.L.T.

Functionally Equivalent Language Translation

MVAR

    (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"))

See also DEFCLASS CLASS CVAR

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.


Alternative Forms

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


Define a member variable

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.

One at a time

To define a member variable you just name the variable within the MVAR instruction like so:

(class Foo (mvar bar))

With default values

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)))

Multiple definitions

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.