Language::Basic::Function - Package to handle user-defined and intrinsic Functions in BASIC.


See Language::Basic for the overview of how the Language::Basic module works. This pod page is more technical.

A Function can be either an intrinsic BASIC function, like INT or CHR$, or a user-defined function, like FNX (defined with the DEF command).


The check_args method checks that the right number and type of function arguments were input.

The evaluate method actually calculates the value of the function, given certain arguments.

The lookup method looks up the function in the function lookup table.

The output_perl method returns a string that's the Perl equivalent to the BASIC function.

Class Language::Basic::Function::Intrinsic

This class handles intrinsic BASIC functions.

The initialize method sets up BASIC's supported functions at the beginning of the program. The all-important @Init holds a ref for each function to an array holding: - the function name, - the number and type of arguments (in a Perl function prototype-like style), - a subref that performs the equivalent of the BASIC function, and - a string for the output_perl method. That string is either the name of an equivalent Perl function, like "ord" for BASIC's "ASC", or (if there is no exact equivalent) a BLOCK that performs the same action. Adding intrinsic BASIC functions therefore involves adding to this array.

Class Language::Basic::Function::Defined

This class handles functions defined by the user in DEF statements.