Misc
class
prop: class
embedded class decls, for namespace and other
class
class decl
anon class. class without name….Demo
class
prop inline class
function which sets is same as prop?
Variable – like a property, but without getters, setters etc… .. when in type, a field? syntax compat….. or better yet.. DONT allow on type.. explain why… for func local only where func KNOWS all about it and dont want internals ever changed.. but a type should be fully dynamic…..
————————
Terms
- Type – A definition used to create an object.
- Object – An instance of a type.
- Property
- Function – one way, simple. no setters, no getters, no other support. raw call
Types of Statements in Executable Code
- Assignments / Calls
- Flow Control / Exceptions
Stored Types
Zed must distinguish common types from actual types that can be stored directly as a raw value. In general code should only use a stored type for actual internals and storage or when no extra features are needed. Since usage and syntax is identical, the types can easily be upgraded by the developer later.
Stored types include:
number
can compare based on types of differing internal storage.
.BCD
floats etc..
fixed – or via BCD?
int and uint sizes
boolean
string
strings are immutable.
Extended Types
Any extended type can have a value, or null. Allowing of null can be disabled / enabled as part of the extended type.
string
As an extended type string is mutable.
number
Number as BCD which allows the most flexibility and allows floats. To limit it, use properties of the instance of the type itself.
When declaring in code to create a number type, use a format specifier and short cut for numbers.
0
Zero or positive whole number.
1
Positive whole number
Decimal Suffix
.0
Positive decimal (fixed) number.
–
Prefix any number specifier to also allow negatives. ie, -0 allows 0, and both positive and negative whole numbers.
Ranges
1..100
Allows whole numbers from 1 to 100. When specifying a decimal, only the starting number requires the .0 suffix.
List
[1,5,7]
Can mix decimal and whole numbers.
Range and List
[1..100, 200..255, -1]
-1 etc when in a list or range are literal and do not represent an extended meaning. Spaces are optional around commas.
object instance
Variables
Variables are different than classes, and occupy a different namespace.
x = aaa
Declares x as a new variable of type aaa and initializes it. Once initialized, it is hard typed to aaa and any new assignments are validated for type compat. Cannot declare a variable by reading it, only by setting it.
Doing so generates error on second attempt to assign unless aab descends from aaa.
x = aaa
x = bbb
Can optionally specify a compatible base type instead for polymorphism:
x as base = aaa
An empty instance of a variable can be created using:
x as base
Initializes x as type base (required when no initializer, or for null) with default value for class. If class has no default value, then null is used.
Constructors
Default
type aaa ] x = aaa
= aaa
Simply reference by the class name and ctor is called.
Explicit
type aaa _new: ] ] x = aaa
_ signifies its an integral part of the language which allows future expansion and also allows user to use get and other otherwise conflicting identifiers.
Parameters
type aaa _new[User0]: ] ] x = aaa
If no result is explicitly set by the code, the instance of the object is returned.
Scopes
Any item declared outside of a parent type declaration including type declarations themselves are added to the global space. global can be accessed explicitly using : or without the prefix in most cases. Thus the type aaa is accessible as both :aaa and aaa from items within the aaa scope. Code in other scopes must use the reserved : to access items in the global scope.
This allows procedural code to be written, but execute in a transparent object oriented environment.
Items in other scopes can be accessed using scopename:itemname.
Functions
Functions are self contained executable code
Properties
Properties must be an extended type.