Qore Programming Language Reference Manual 1.12.4
|
A Qore program is composed of a series of declarations, statements, function definitions, and/or class definitions. Non-block statements are terminated by a semi-colon ";". Block statements are grouped by using curly brackets ("{" and "}"), as in C, C++, Java, and Perl.
Programmers familiar with C, C++, Java, and/or Perl should find the standard Qore syntax intuitive and should be productive fairly quickly with the language. However Qore has unique features that differentiate it from other languages, and these features must be mastered in order to leverage the full power of Qore.
Qore programs/scripts are free form. Formatting does not affect the execution of the program; formatting is at the discretion of the programmer and should be used to enhance readability and clarity of the source code.
Qore was created as a weakly typed language. That means that variables (without type restrictions) can hold values of any type and functions (without a return type restriction or parameter type descriptions) can return any data type and take arguments of any type. Furthermore list elements can be of any type (they do not have to be uniform), and multidimensional lists can have a different number of elements in each list. The same type flexibility holds true of hashes, objects, and all combinations of container types.
Qore also allows variable, parameter, class member, and return types to be declared, so that APIs can be formally defined or the programmer can decide to declare types to catch more errors at parse time (which is often preferable to discovering a type error at runtime).
Qore can be used as a traditional function-based scripting language or as a pure object-oriented language, where the application is defined as a class. Aside from traditional local and global variables, constants, and functions, Qore also supports nested namespaces, classes, multiple inheritance, overriding base class constructor arguments, public and private members and methods, static class methods, and static class variables.
All elements of Qore are designed to work together: database access, socket communication, embedding logic in subprograms, regular expressions, operators, functions, and all other elements are thread-safe and built on an execution engine that was designed for SMP scalability.
Qore automatically converts data types when necessary when evaluating operators. The goal is to provide the expected result for the programmer without requiring the programmer to explicitly convert data types. Please see Operators for more information.
Qore supports signal handling by executing Qore-language signal handlers in special signal-handling thread.
UNIX operating systems allow an executable script to specify their interpreter. This is done by setting the first line of the script to a special string indicating the location of the interpreter (Qore binary). For the purposes of this document, the location for the qore
binary is assumed to be /usr/bin/qore
. The first line of Qore scripts in this case should look as follows:
Qore is moving toward establishing %new-style as the default syntax; all examples given in the Qore documentation are given assuming %new-style. To use Qore with the recommended parse directives, the following can be used as an example:
/usr/local/bin
), then the correct path must be reflected in the first line of the Qore script (ex: #!/usr/local/bin/qore
), or more portably without using a direct path to the interpreter: qore
binary is in the current PATH
.Qore convention dictates that Qore script file names end with ".q"
; user modules with ".qm"
, and test scripts with ".qtest"
.