Qore Programming Language Reference Manual  0.8.11.1
Parse Directives

Qore supports the use of parse directives in order to set parsing options, load modules, control warnings, and include other files.

Parse directives that set parsing options can be used any time parse options have not been locked on a Program object. They are used most often when it's not possible or desirable to set the parse options in the qore command line.

Parse Directives

Directive Description
%allow-bare-refs Prohibits the use of the "$" character in variable names, method calls, and object member references. This makes Qore scripts appear superficially more like C++ or Java programs.

This parse option is set by default with %new-style.

Name resolution is made in the following order when this option is set: local variables, class constants and static class vars (when parsing in class code), global variables, and (non-class) constants.

Note that implicit arguments are still referenced with the "$" character even when this parse option is set; see also %require-dollar

Since Qore 0.8.1
%append-include-path Appends the given directories to qore's include path; also performs environment variable substitution
%append-module-path Appends the given directories to qore's module path; also performs environment variable substitution

Since Qore 0.8.6
%assume-global Resets the default Qore behavior of assuming global variable scope when variables are first referenced if no my or our is present; use after %assume-local to reset the default parsing behavior.

This parse option is also set with %old-style

Since Qore 0.8.4
%assume-local Assume local variable scope when variables are first referenced if no my or our is present. When used with %allow-bare-refs, local variables without my must be declared with a data type restriction (can be any).

This parse option is set by default with %new-style; see also %assume-global

Since Qore 0.8.1
%define Creates and optionally sets a value for a parse define

Since Qore 0.8.3
%disable-all-warnings Turns off all warnings
%disable-warning warning-code Disables the named warning until %enable-warning is encountered with the same code or %enable-all-warnings is encountered
%else Allows for parsing an alternate block when used with the %ifdef or %ifndef parse directives (for conditional parsing based on parse defines)

Since Qore 0.8.3
%enable-all-warnings Turns on all warnings
%enable-warning warning-code Enables the named warning
%endif Closes a conditionally-parsed block started by the %ifdef or %ifndef parse directives

Since Qore 0.8.3
%endtry Closes a %try-module block

Since Qore 0.8.6
%exec-class class_name Instantiates the named class as the application class; also turns on %no-top-level. If the program is read from stdin or from the command line, an argument must be given specifying the class name
%ifdef Opens a conditionally-parsed block; if the given parse define is defined, then the block after the %ifdef is parsed until either an %else or an %endif

Since Qore 0.8.3
%ifndef Opens a conditionally-parsed block; if the given parse define is not defined, then the block after the %ifdef is parsed until either an %else or an %endif

Since Qore 0.8.3
%include file_name Starts parsing file_name immediately. Parsing resumes with the current input after file_name has been completely parsed
%lockdown Made up of %no-external-access, %no-threads, and %no-io; equivalent to parse option Qore::PO_LOCKDOWN and the –lockdown command line option
%lock-options Prohibits further changes to parse options (equivalent to the --lock-options command line option)
%lock-warnings Prohibits further changes to the warning mask (equivalent to the --lock-warnings command line option)
%new-style Sets both %allow-bare-refs and %assume-local. These two options together make programming in Qore superficially more like programming in C++ or Java programs; use this if you dislike programming with the "$" sign, for example; see also %old-style

Since Qore 0.8.1
%old-style Resets default Qore parsing behavior by setting %require-dollar and %assume-global; this option is the opposite of %new-style

Since Qore 0.8.4
%no-class-defs Disallows class definitions; equivalent to Qore::PO_NO_CLASS_DEFS and the --no-class-defs command line option
%no-child-restrictions Allows child program objects to have parse option restrictions that are not a strict subset of the parents'; equivalent to parse option Qore::PO_NO_CHILD_PO_RESTRICTIONS and the --no-child-restrictions command line option
%no-constant-defs Disallows constant definitions; equivalent to parse option Qore::PO_NO_CONSTANT_DEFS and the --no-constant-defs command line option
%no-database Disallows access to database functionality (for example the Datasource class; equivalent to parse option Qore::PO_NO_DATABASE and the --no-database command line option
%no-external-access made up of %no-process-control, %no-network, %no-filesystem, %no-database, %no-external-info, and %no-modules; equivalent to parse option Qore::PO_NO_EXTERNAL_ACCESS and the --no-external-access command line option
%no-external-info Disallows any access to functionality that provides external information (see %no-external-info for a list of features not available with this parse option); equivalent to parse option Qore::PO_NO_EXTERNAL_INFO and the --no-external-info command line option
%no-external-process Disallows any access to external processes (see %no-external-process for a list of features not available with this parse option); equivalent to parse option Qore::PO_NO_EXTERNAL_PROCESS and the --no-external-process command line option
%no-filesystem Disallows access to the local filesystem; equivalent to parse option Qore::PO_NO_FILESYSTEM and the --no-filesystem command line option
%no-global-vars Disallows the use of global variables; equivalent to parse option Qore::PO_NO_GLOBAL_VARS and the --no-global-vars command line option
%no-gui Disallows functionality that draws graphics to the display; equivalent to parse option Qore::PO_NO_GUI and the -pno-gui command line option
%no-io Made up of %no-gui | %no-terminal-io | %no-filesystem | %no-network | %no-database; equivalent to parse option Qore::PO_NO_IO and the –no-io command line option
%no-locale-control Disallows access to functionality that changes locale information (see no-locale-control for a list of features not available with this parse option); equivalent to parse option Qore::PO_NO_LOCALE_CONTROL and the --no-locale-control command line option
%no-modules Disallows loading modules with the %requires or %try-module parse directive or at runtime with load_module(); equivalent to Qore::PO_NO_MODULES and the -pno-modules command line option

Since Qore 0.8.4
%no-namespace-defs Disallows new namespace definitions; equivalent to Qore::PO_NO_NAMESPACE_DEFS and the --no-namespace-defs command line option
%no-network Disallows access to the network; equivalent to parse option Qore::PO_NO_NETWORK and the --no-network command line option
%no-new Disallows use of the new operator; equivalent to parse option Qore::PO_NO_NEW and the --no-new command line option
%no-process-control Disallows access to functions that would affect the current process (see %no-process-control for a list of features not available with this parse option); equivalent to parse option Qore::PO_NO_PROCESS_CONTROL and the --no-process-control command line option
%no-subroutine-defs Disallows subroutine (function) definitions; equivalent to parse option Qore::PO_NO_SUBROUTINE_DEFS and the --no-subroutine-defs command line option
%no-terminal-io Disallows access to terminal I/O (see %no-terminal-io for a list of features not available with this parse option); equivalent to parse option Qore::PO_NO_TERMINAL_IO and the -pno-terminal-io command line option
%no-thread-classes Disallows access to thread classes (see %no-thread-classes for a list of features not available with this parse option); equivalent to parse option Qore::PO_NO_THREAD_CLASSES and the --no-thread-classes command line option
%no-thread-control Disallows access to thread control operations (see %no-thread-control for a list of features not available with this parse option); equivalent to parse option Qore::PO_NO_THREAD_CONTROL and the --no-thread-control command line option
%no-thread-info Disallows any access to functionality that provides threading information (see %no-thread-info for a list of features not available with this parse option); equivalent to parse option Qore::PO_NO_THREAD_INFO and the --no-thread-info command line option
%no-threads Disallows access to all thread control operations and thread classes (equivalent to --no-thread-control and --no-thread-classes together); equivalent to parse option Qore::PO_NO_THREADS and the --no-threads command line option
%no-top-level Disallows top level code; equivalent to parse option Qore::PO_NO_TOP_LEVEL_STATEMENTS and the --no-top-level command line option
%perl-bool-eval Set to mimic perl's boolean evaluation; this is the default with qore >= 0.8.6; prior to this version, by default qore used strict mathematic boolean evaluation, where any value converted to 0 is False and otherwise it's is True.

As of Qore 0.8.6+, this parse option is only needed if %strict-bool-eval is set.

When this option is set, boolean evaluation follows the same rules as <value>::val(); see also %strict-bool-eval

Since Qore 0.8.6
%push-parse-options Stores parse options so that they will be restored when the current file is done parsing; use in include files to ensure parse options are set appropriately for the file being parsed
%require-dollar Resets the default Qore behavior where the use of the "$" character in variable names, method calls, and object member references is required; use after %allow-bare-refs to reset the default parsing behavior

Since Qore 0.8.4
%require-our Requires global variables to be declared with our prior to use (like perl's use strict vars pragma); equivalent to parse option Qore::PO_REQUIRE_OUR and the --require-our command line option
%require-prototypes Requires type declarations for all function and method parameters and return types. Variables and object members do not need to have type declarations; equivalent to parse option Qore::PO_REQUIRE_PROTOTYPES and the --require-prototypes command line option

Since Qore 0.8.0
%require-types Requires type declarations for all function and method parameters, return types, variables, and object members; equivalent to parse option Qore::PO_REQUIRE_TYPES and the --require-types command line option; also implies %strict-args

Since Qore 0.8.0
%requires feature [<|<=|=|>=|> version] If the named feature is not already present in Qore, then the QORE_MODULE_DIR environment variable is used to provide a list of directories to seach for a module with the same name (feature[-api-x.y].qmod for binary modules or feature.qm for user modules). If the module is not found, then the qore default module directory is checked.

This directive must be used to load modules providing parse support (i.e. modules providing classes, constants, functions, etc that are resolved at parse time).

If version information is provided, then it is compared with the module's version information, and if it does not match a parse exception is raised.

See also Qore::load_module() for a function providing run-time module loading and %try-module for a similar parse directive that allows module loading errors to be handled at runtime
%set-time-zone Sets the time zone for the current program from a UTC offset (with format "+/-[00[:00[:00]]"; ":" characters are optional) or a time zone region name (ex: "Europe/Prague")

Since Qore 0.8.3
%strict-args Prohibits access to builtin functions and methods flagged with RUNTIME_NOOP and also causes errors to be raised if excess arguments are given to functions that do not access excess arguments

Since Qore 0.8.0
strict-bool-eval Sets qore's default strict mathematic boolean evaluation mode, where any value converted to 0 is False and otherwise it's is True; this was how qore behaved by default prior to v0.8.6.

Equivalent to parse option Qore::PO_STRICT_BOOLEAN_EVAL and the -pstrict-bool-eval command line option.

See also %perl-bool-eval

Since Qore 0.8.6
%try-module (var_decl) feature [<|<=|=|>=|> version] If the named feature is not already present in Qore, then the QORE_MODULE_DIR environment variable is used to provide a list of directories to seach for a module with the same name (feature[-api-x.y].qmod for binary modules or feature.qm for user modules). If the module is not found, then the qore default module directory is checked.

If an error occurs loading the module, then the variable declared after %try-module is instantiated with the exception information, and the code up to the %endtry parse declaration is parsed into the program, allowing for the qore script/program to handle module loading errors at parse time for modules that must be loaded at parse time.

If version information is provided, then it is compared with the module's version information, and if it does not match a parse exception is raised that is handled like any other load error.

See also Qore::load_module() for a function providing run-time module loading and %requires for a similar declaration that does not allow for parse-time module loading error handling.

Since Qore 0.8.6

%allow-bare-refs

Parse Directive:
%allow-bare-refs
Command Line:
--allow-bare-refs, -B
Parse Option Constant:
Qore::PO_ALLOW_BARE_REFS
Description:
Prohibits the use of the "$" character in variable names, method calls, and object member references. This makes Qore scripts appear superficially more like C++ or Java programs. This parse option is set by default with %new-style and is the opposite of %require-dollar.

Name resolution is made in the following order when this option is set:
Since
Qore 0.8.1
See also
%require-dollar

%append-include-path

Parse Directive:
%append-include-path dir1[:dir2...]
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Appends the given directories to qore's include path; also performs environment variable substitution. Only directories that exist and are readable are added to the include path.
See also
%append-module-path

%append-module-path

Parse Directive:
%append-module-path dir1[:dir2...]
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Appends the given directories to qore's module path; also performs environment variable substitution. Only directories that exist and are readable are added to the module path.
Since
Qore 0.8.6
See also
%append-include-path

%assume-global

Parse Directive:
%assume-global
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Resets the default Qore behavior of assuming global variable scope when variables are first referenced if no my or our is present; use after %assume-local to reset the default parsing behavior. This parse option is also set with %old-style
Since
Qore 0.8.4
See also
%assume-local

%assume-local

Parse Directive:
%assume-local
Command Line:
--assume-local
Parse Option Constant:
Qore::PO_ASSUME_LOCAL
Description:
Assume local variable scope when variables are first referenced if no my or our is present. When used with %allow-bare-refs, local variables without my must be declared with a data type restriction (can be any). This parse option is set by default with %new-style and is the opposite of %assume-global
Since
Qore 0.8.1
See also
%assume-global

%define

Parse Directive:
%define
Command Line:
--define, -D
Parse Option Constant:
n/a
Description:
Creates and optionally sets a value for a parse define
Since
Qore 0.8.3

%disable-all-warnings

Parse Directive:
%disable-all-warnings
Command Line:
n/a, warnings are disabled by default
Parse Option Constant:
n/a
Description:
Disables all warnings while parsing. See Warnings for more information.

%disable-warning

Parse Directive:
%disable-warning
Command Line:
n/a, warnings are disabled by default
Parse Option Constant:
n/a
Description:
Disables the named warning while parsing. See Warnings for more information.

%else

Parse Directive:
%else
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Allows for parsing an alternate block when used with the %ifdef or %ifndef parse directives (for conditional parsing based on parse defines)
Since
Qore 0.8.3

%enable-all-warnings

Parse Directive:
%enable-all-warnings
Command Line:
--enable-all-warnings, -W
Parse Option Constant:
n/a
Description
Enables all warnings while parsing. See Warnings for more information.

%enable-warning

Parse Directive:
%enable-warning
Command Line:
--enable-warning, -w
Parse Option Constant:
n/a
Description:
Enables the named warning while parsing. See Warnings for more information.

%endif

Parse Directive:
%endif
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Closes a conditionally-parsed block started by the %ifdef or %ifndef parse directives (for conditional parsing based on parse defines)
Since
Qore 0.8.3

%endtry

Parse Directive:
%endtry
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Closes a %try-module block
Since
Qore 0.8.6

%exec-class

Parse Directive:
%exec-class
Command Line:
--exec-class, -x
Parse Option Constant:
n/a
Description:
Executes the named class as the application class and turns on %no-top-level as well.

%ifdef

Parse Directive:
%ifdef
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Opens a conditionally-parsed block; if the given parse define is defined, then the block after the %ifdef is parsed until either an %else or an %endif
Since
Qore 0.8.3

%ifndef

Parse Directive:
%ifndef
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Opens a conditionally-parsed block; if the given parse define is not defined, then the block after the %ifndef is parsed until either an %else or an %endif
Since
Qore 0.8.3

%include

Parse Directive:
%include
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Includes a file to be parsed. If the path is not absolute (i.e. starting with ""/"), then files are searched first in the directory of the currently-executing script (if known), then in each path in the environment variable QORE_INCLUDE_DIR.
If the first character of the include target is '$', then environment variable substitution is performed on the leading environment variable
Since
Qore 0.8.9 added environment variable substitution

%lockdown

Parse Directive:
%lockdown
Command Line:
--lockdown
Parse Option Constant:
Qore::PO_LOCKDOWN
Description:
The most restrictive parse restriction, making any external access, threading, i/o, etc illegal. Made up of %no-external-access, %no-threads, and %no-io

%lock-options

Parse Directive:
%lock-options
Command Line:
--lock-options, -K
Parse Option Constant:
n/a
Description:
Prohibits further changes to parse options.

%lock-warnings

Parse Directive:
%lock-warnings
Command Line:
--lock-warnings, -A
Parse Option Constant:
Qore::PO_LOCK_WARNINGS
Description:
Prohibits further changes to the warning mask.

%new-style

Parse Directive:
%new-style
Command Line:
--new-style, -n
Parse Option Constant:
Qore::PO_NEW_STYLE
Description:
Sets both %allow-bare-refs and %assume-local. These two options together make programming in Qore superficially more like programming in C++ or Java programs; use this if you dislike programming with the "$" sign, for example.
See also
%old-style
Since
Qore 0.8.1

%old-style

Parse Directive:
%old-style
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Resets default Qore parsing behavior by setting %require-dollar and %assume-global; this option has the opposite effect of %new-style
See also
%new-style
Since
Qore 0.8.4

%no-child-restrictions

Parse Directive:
%no-child-restrictions
Command Line:
--no-child-restrictions, -I
Parse Option Constant:
Qore::PO_NO_CHILD_PO_RESTRICTIONS
Description:
Allows child program objects to have parse option restrictions that are not a strict subset of the parents'.

%no-class-defs

Parse Directive:
%no-class-defs
Command Line:
--no-class-defs
Parse Option Constant:
Qore::PO_NO_CLASS_DEFS
Description:
Disallows new class definitions. Any use of the reserved word class will result in a parse exception.

%no-constant-defs

Parse Directive:
%no-constant-defs
Command Line:
--no-constant-defs
Parse Option Constant:
Qore::PO_NO_CONSTANT_DEFS
Description:
Disallows new constant definitions. Any use of the reserved word const will result in a parse exception.

%no-database

Parse Directive:
%no-database
Command Line:
--no-database
Parse Option Constant:
Qore::PO_NO_DATABASE
Description:
Disallows access to database functionality. Currently this means that access to the following classes is restricted:

%no-external-access

Parse Directive:
%no-external-access
Command Line:
--no-external-access
Parse Option Constant:
Qore::PO_NO_EXTERNAL_ACCESS
Description:
This option is made up of %no-process-control, %no-network, %no-filesystem, %no-database, %no-external-info, and %no-modules
See also
%lockdown

%no-external-info

Parse Directive:
%no-external-info
Command Line:
--no-external-info
Parse Option Constant:
Qore::PO_NO_EXTERNAL_INFO
Description:
Disallows any access to functionality that provides external information. The following features are unavailable with this option:

%no-external-process

Parse Directive:
%no-external-process
Command Line:
--no-external-process, -E
Parse Option Constant:
Qore::PO_NO_EXTERNAL_PROCESS
Description:
Disallows any access to external processes. The following features are unavailable with this option:

%no-filesystem

Parse Directive:
%no-filesystem
Command Line:
--no-filesystem, -F
Parse Option Constant:
Qore::PO_NO_FILESYSTEM
Description:
Disallows any access to the external filesystem. The following features are unavailable with this option:

%no-global-vars

Parse Directive:
%no-global-vars
Command Line:
--no-global-vars, -G
Parse Option Constant:
Qore::PO_NO_GLOBAL_VARS
Description:
Disallows the use of global variables.

%no-gui

Parse Directive:
%no-gui
Command Line:
--no-gui, –set-parse-option=no-gui, -pno-gui
Parse Option Constant:
Qore::PO_NO_GUI
Description:
Disallows the use of functionality that draws graphics to the display (this functionality is not implemented in the qore library; only implemented in modules).

%no-io

Parse Directive:
%no-io
Command Line:
--no-io, –set-parse-option=no-io, -pno-io
Parse Option Constant:
Qore::PO_NO_IO
Description:
Made up of %no-gui | %no-terminal-io | %no-filesystem | %no-network | %no-database

%no-locale-control

Parse Directive:
%no-locale-control
Command Line:
--no-locale-control, -P
Parse Option Constant:
Qore::PO_NO_LOCALE_CONTROL
Description:
Disallows access to functions that would affect the locale settings of the current program. The following features are unavailable with this option:

%no-modules

Parse Directive:
%no-modules
Command Line:
-pno-modules
Parse Option Constant:
Qore::PO_NO_MODULES
Description:
Disallows loading modules with the %requires or %try-module directives or at runtime with load_module()
Since
Qore 0.8.4

%no-namespace-defs

Parse Directive:
%no-namespace-defs
Command Line:
--no-namespace-defs, -M
Parse Option Constant:
Qore::PO_NO_NAMESPACE_DEFS
Description:
Disallows new namespace definitions.

%no-network

Parse Directive:
%no-network
Command Line:
--no-network, -Y
Parse Option Constant:
Qore::PO_NO_NETWORK
Description:
Disallows any access to the network. The following features are unavailable with this option:

%no-new

Parse Directive:
%no-new
Command Line:
--no-new, -N
Parse Option Constant:
Qore::PO_NO_NEW
Description:
Disallows use of the new operator.

%no-process-control

Parse Directive:
%no-process-control
Command Line:
--no-process-control, -P
Parse Option Constant:
Qore::PO_NO_PROCESS_CONTROL
Description:
Disallows access to functions that would affect the current process. The following features are unavailable with this option:

%no-subroutine-defs

Parse Directive:
%no-subroutine-defs
Command Line:
--no-subroutine-defs, -S
Parse Option Constant:
Qore::PO_NO_SUBROUTINE_DEFS
Description:
Disallows subroutine (function) definitions.

%no-terminal-io

Parse Directive:
%no-terminal-io
Command Line:
--no-terminal-io,--set-parse-option=no-terminal-io, -pno-terminal-io
Parse Option Constant:
Qore::PO_NO_TERMINAL_IO
Description:
Disallows access to terminal input and output. The following features are unavailable with this option:

%no-thread-classes

Parse Directive:
%no-thread-classes
Command Line:
--no-thread-classes
Parse Option Constant:
Qore::PO_NO_THREAD_CLASSES
Description:
Disallows access to thread classes. The following features are unavailable with this option:

%no-thread-control

Parse Directive:
%no-thread-control
Command Line:
--no-thread-control, -R
Parse Option Constant:
Qore::PO_NO_THREAD_CONTROL
Description:
Disallows access to thread control operations. The following features are unavailable with this option:

%no-thread-info

Parse Directive:
%no-thread-info
Command Line:
--no-thread-info
Parse Option Constant:
Qore::PO_NO_THREAD_INFO
Description:
Disallows access to functionality that provides information about threading. The following features are unavailable with this option:

%no-threads

Parse Directive:
%no-threads
Command Line:
--no-threads, -T
Parse Option Constant:
Qore::PO_NO_THREADS
Description:
Disallows access to all thread control operations and thread classes (equivalent to %no-thread-control and %no-thread-classes together).

%no-top-level

Parse Directive:
%no-top-level
Command Line:
--no-top-level, -L
Parse Option Constant:
Qore::PO_NO_TOP_LEVEL_STATEMENTS
Description:
Disallows top level code.

%perl-bool-eval

Parse Directive:
%perl-bool-eval
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Set to mimic perl's (and Python's) boolean evaluation; this is now the default (as of qore version 0.8.6); prior to this version, by default qore used strict mathematic boolean evaluation, where any value converted to 0 is False and otherwise it's is True.

As of Qore 0.8.6+, %perl-bool-eval is the default behavior and therefore only needs to be set if %strict-bool-eval was set first.

When this option is set, boolean evaluation follows the same rules as <value>::val(); for example:
my string $str = "hello";
if ($str)
printf("string is: %y\n", $str);

With this option set (the default), the above prints out:
string is: "hello"
When it's not set (i.e. %strict-bool-eval is set), nothing is printed out as the string expression evaluates to False due to qore's old strict mathematical boolean evaluation.

Basically with this option set, qore's boolean evaluation becomes like perl's and Python's, whereas any expression that has the following values is False: NOTHING, string "0" and empty strings, integer, float, and number 0 (zero), absolute date 1970-01-01Z (ie the start of the epoch with an offset of 0), relative date PT0H (ie any relative date with a 0 duration), NULL, empty binary objects, empty hashes, and empty lists. All other values are True.
Note
also affects the boolean(any) function
See also
%strict-bool-eval
Since
Qore 0.8.6

%push-parse-options

Parse Directive:
%push-parse-options
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Stores parse options so that they will be restored when the current file is done parsing; use in include files to ensure parse options are set appropriately for the file being parsed.

For example:
%push-parse-options
%new-style

%require-dollar

Parse Directive:
%require-dollar
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Resets the default Qore behavior where the use of the "$" character in variable names, method calls, and object member references is required; use after %allow-bare-refs to reset the default parsing behavior
Since
Qore 0.8.4

%require-our

Parse Directive:
%require-our
Command Line:
--require-our, -O
Parse Option Constant:
Qore::PO_REQUIRE_OUR
Description:
Requires global variables to be declared with our prior to use (recommended to use for all larger scripts/programs).

%require-prototypes

Parse Directive:
%require-prototypes
Command Line:
--require-prototypes
Parse Option Constant:
Qore::PO_REQUIRE_PROTOTYPES
Description:
Requires type declarations for all function and method parameters and return types. Variables and object members do not need to have type declarations with this option.
See also
%require-types, which is a superset of this option.

%require-types

Parse Directive:
%require-types
Command Line:
--require-types
Parse Option Constant:
Qore::PO_REQUIRE_TYPES
Description:
Requires type declarations for all function and method parameters, return types, variables, and object members.
See also
%require-prototypes, which is a subset of this option.

%requires

Parse Directive:
%requires feature [<|<=|=|>=|> version]
Command Line:
--load, -l
Parse Option Constant:
n/a
Description:
Loads a Qore module immediately. The parse directive can be used to load a module during parsing, and the command line version can be used to load a module before parsing.

From Qore 0.7.1, you can specify a comparison operator (one of <, <=, =, >=, or >) and version information after the module name as well. Version numbers are compared via integer comparisons of each element, where elements are separated by a ".". If one of the versions does not have as many elements as another, the missing elements are assumed to be "0" (i.e. version "1.0" compared with version "1.0.1" will be extended to "1.0.0").

For example:
%requires oracle >= 1.0.1

This will load the oracle module if it is at least version 1.0.1.

Note that there is one special feature name: "qore". This pseudo-feature can be used to check the minimum Qore version; if this feature is requested with version information, then the Qore library's version information is used for the version number comparison.
See also
%try-module for a similar parse directive that allows module loading errors to be caught and handled at parse-time

%set-time-zone

Parse Directive:
%set-time-zone
Command Line:
--time-zone, -z
Parse Option Constant:
none; this is set by calling Qore::TimeZone::setRegion() or Qore::TimeZone::setUTCOffset()
Description:
Sets the time zone for the current program from a UTC offset (with format "+/-00[:00[:00]]"; ":"" characters are optional) or a time zone region name (ex: \c "Europe/Prague").

%strict-args

Parse Directive:
%strict-args
Command Line:
--strict-args
Parse Option Constant:
Qore::PO_STRICT_ARGS
Description:
Prohibits access to builtin functions and methods flagged with RUNTIME_NOOP and also causes errors to be raised if excess arguments are given to functions that do not access excess arguments.

%strict-bool-eval

Parse Directive:
%strict-bool-eval
Command Line:
-pstrict-bool-eval
Parse Option Constant:
Qore::PO_STRICT_BOOLEAN_EVAL
Description:
When set, this option enables qore's default strict mathematic boolean evaluation, where any value converted to 0 is False and otherwise it's is True.

This option takes effect at runtime.

For example:
my string $str = "hello";
if ($str)
printf("string is: %y\n", $str);

If %strict-bool-eval is set, then Qore's boolean evaluation will evaluate "hello" in a strict mathematical sense and convert it to 0, which is False, so nothing would be printed out, but when %perl-bool-eval is enabled, this will be True (following the rules for <string>::val()).

Qore's strict mathematical boolean evaluation was the default prior to Qore 0.8.6, however it was considered non-intuitive and a design bug, and therefore the default behavior of the language was changed to a more intuitive form of boolean evaluation as documented in %perl-bool-eval.
Note
also affects the boolean(any) function
See also
perl-bool-eval
Since
Qore 0.8.6

%try-module

Parse Directive:
%try-module [(var_decl)] feature [<|<=|=|>=|> version]
Command Line:
n/a
Parse Option Constant:
n/a
Description:
Loads a Qore module immediately; if an error occurs loading the module, then the variable declared in parentheses after %try-module is instantiated with the exception information, and the code up to the %endtry parse declaration is parsed into the program, allowing for the qore script/program to handle module loading errors at parse time for modules that must be loaded at parse time.

A comparison operator (one of <, <=, =, >=, or >) and version information can be optionally given after the module name as well. Version numbers are compared via integer comparisons of each element, where elements are separated by a ".". If one of the versions does not have as many elements as another, the missing elements are assumed to be "0" (i.e. version "1.0" compared with version "1.0.1" will be extended to "1.0.0"). Version errors are handled in the same was as any other module loading error.

For example:
%try-module($ex) some_module > 2.0
printf("error loading module %y: %s: %s\n", $ex.arg, $ex.err, $ex.desc);
exit(1);
%endtry

This will load the "some_module" module if it is at least version 2.0, and print an error message and exit gracefully if it cannot be loaded.

The variable declaration in parentheses is optional; use the variant without the exception variable in code where parse option PO_NO_TOP_LEVEL_STATEMENTS is set, for example. In this case, for example, other parse options can be set before the %endtry directive.

Here is an example without a variable declaration in parentheses:
%try-module some_module > 2.0
%define DontHaveSomeModule
%endtry

Note that there is one special feature name: "qore". This pseudo-feature can be used to check the minimum Qore version; if this feature is requested with version information, then the Qore library's version information is used for the version number comparison.
See also
%requires for a similar parse directive where errors are handled with the default parse exception handler
Since
Qore 0.8.6; the variant without the variable declaration was introduced in Qore 0.8.6.1