Built-in Data Types
xHarbour has 6 scalar types : Nil, String, Date, Logical, Number, Pointer, and 4 complex types: Array, Object, CodeBlock, and Hash. A scalar holds a single value, such as a string, number, or reference to any other type. Arrays are ordered lists of scalars or complex types, indexed by number, starting at 1. Hashes, or associative arrays, are unordered collections of any type values indexed by their associated key, which may be of any scalar or complex type.
Literal (static) representation of scalar types:
- Nil: NIL
- String: "hello", 'hello', or E"hello\n"
- Date: ctod("2005-03-17" )
- Logical: .T., .F.
- Number: 1, 1.1, -1, 0xFF
Complex Types may also be represent as literal values:
- Array: { "String"", 1, { "Nested Array" }, .T., FunctionCall, @FunctionPointer }
- CodeBlock: { |Arg1, ArgN| Arg1 := ArgN + OuterVar + FunctionCall }
- Hash: { "Name" => "John", 1 => "Numeric key", { "Nested" => "Hash" } }
Hashes may use any type including other Hashes as the Key for any element. Hashes and Arrays may contain any type as the Value of any member, including nesting arrays, and Hashes.
Codeblocks may have references to Variables of the Procedure/Function>method in which it was defined. Such Codeblocks may be returned as a value, or by means of an argument passed BY REFERENCE, in such case the Codeblock will "outlive" the routine in which it was defined, and any variables it references, will be a DETACHED variable.
Detached variables will maintain their value for as long as a Codeblock referencing them still exists. Such values will be shared with any other Codeblock which may have access to those same variables. If the Codeblock did not outlive its containing routine, and will be evaluated within the lifetime of the routine in which it is defined, changes to its Detached Variables(s) by means of its evaluation, will be reflected back at its parent routine.
Codeblocks can be evaluated any number of times, by means of the Eval( BlockExp ) function.
Read more about this topic: XHarbour
Famous quotes containing the words built-in, data and/or types:
“Because there is very little honor left in American life, there is a certain built-in tendency to destroy masculinity in American men.”
—Norman Mailer (b. 1923)
“Mental health data from the 1950s on middle-aged women showed them to be a particularly distressed group, vulnerable to depression and feelings of uselessness. This isnt surprising. If society tells you that your main role is to be attractive to men and you are getting crows feet, and to be a mother to children and yours are leaving home, no wonder you are distressed.”
—Grace Baruch (20th century)
“... there are two types of happiness and I have chosen that of the murderers. For I am happy. There was a time when I thought I had reached the limit of distress. Beyond that limit, there is a sterile and magnificent happiness.”
—Albert Camus (19131960)