The Ceylon language module containing the core definitions referred to by the language specification, along with some basic functionality of use to most programs:
ceylon.language.meta
and its subpackages
ceylon.language.meta.model
and
ceylon.language.meta.declaration
, which
define interfaces for interacting with applied types and
unapplied type declarations respectively.This module defines an abstraction over the basic facilities of the Java or JavaScript virtual machine, containing only functionality that can be easily implemented on both platforms. Thus, certain functionality, for example, concurrency, for which there is no common virtual machine-agnostic model, is not covered by the language module.
The language module is an implicit dependency of every other Ceylon module, and may not be explicitly imported.
Packages | |
ceylon.language | The root package of the Ceylon language module, functioning as the core of the Ceylon platform, and covering the… |
ceylon.language.meta | The Ceylon metamodel base package. |
ceylon.language.meta.declaration | The Ceylon metamodel open type and declaration package. |
ceylon.language.meta.model | The Ceylon metamodel closed type and model package. |
ceylon.language.serialization | The Ceylon serialization infrastructure. |
Dependencies | ||
java.base (jvm) | 7 |
The root package of the Ceylon language module, functioning as the core of the Ceylon platform, and covering the following areas of functionality:
Anything
, Object
, and
Null
, and a logical boolean type,process
, and operating system, andFinally, this module defines the most useful and interesting void function of all time ever.
Declarations belonging to this package need not be explicitly imported by other source files.
Annotations | |
abstract | Source Codeshared AbstractAnnotation abstract() Annotation to mark a class as abstract. An |
actual | Source Codeshared ActualAnnotation actual() Annotation to mark a member of a type as refining a member of a supertype. |
aliased | Source Codeshared AliasesAnnotation aliased(String[] aliases) Annotation to specify a list of aliases that tools such as auto-completion and quick-fixes should consider, to help users find a declaration using its aliases. Parameters:
|
annotation | Source Codeshared AnnotationAnnotation annotation() Annotation to mark a class as an annotation class, or a top-level function as an annotation constructor. See also Annotation |
by | Source Codeshared AuthorsAnnotation by(String[] authors) Annotation to document the authors of an API. Parameters:
|
default | Source Codeshared DefaultAnnotation default() Annotation to mark a member whose implementation may be
refined by subtypes. Non- |
deprecated | Source Codeshared DeprecationAnnotation deprecated(String reason = "") Annotation to mark program elements which should not be used anymore. Parameters:
|
doc | Source Codeshared DocAnnotation doc(String description) Annotation to specify API documentation of a program element. Parameters:
|
final | Source Codeshared FinalAnnotation final() Annotation to mark a class as final. A |
formal | Source Codeshared FormalAnnotation formal() Annotation to mark a member whose implementation must be provided by subtypes. |
late | Source Codeshared LateAnnotation late() Annotation to disable definite initialization analysis for a reference. |
license | Source Codeshared LicenseAnnotation license(String description) Annotation to specify the URL of the license of a module or package. Parameters:
|
native | Source Codeshared NativeAnnotation native(String[] backends) Annotation to mark a member whose implementation is defined in platform-native code. |
optional | Source Codeshared OptionalImportAnnotation optional() Annotation to specify that a module can be executed even if the annotated dependency is not available. |
sealed | Source Codeshared SealedAnnotation sealed() Annotation to mark an interface, class, or constructor as
sealed. A |
see | Source Codeshared SeeAnnotation see(Declaration[] programElements) Annotation to specify references to other program elements related to the annotated API. Parameters:
|
serializable | Source Codeshared SerializableAnnotation serializable() Annotation to specify that a class is serializable. A serializable class may have instances that cannot be serialized if those instances have reachable references to instances of non-serializable classes. |
shared | Source Codeshared SharedAnnotation shared() Annotation to mark a declaration as shared. A |
suppressWarnings | Source Codeshared SuppressWarningsAnnotation suppressWarnings(String[] warnings) Annotation to suppress compilation warnings of the specified types when typechecking the annotated program element. Parameters:
|
tagged | Source Codeshared TagsAnnotation tagged(String[] tags) Annotation to categorize an API by tag. Parameters:
|
throws | Source Codeshared ThrownExceptionAnnotation throws(Declaration type, String when = "") Annotation to document the exception types thrown by a function, value, class, or constructor. Parameters:
|
variable | Source Codeshared VariableAnnotation variable() Annotation to mark a value as variable. A |
AbstractAnnotation | Source Codeshared final AbstractAnnotation The annotation class for the |
ActualAnnotation | Source Codeshared final ActualAnnotation The annotation class for the |
AliasesAnnotation | Source Codeshared final AliasesAnnotation The annotation class for the |
AnnotationAnnotation | Source Codeshared final AnnotationAnnotation The annotation class for the |
AuthorsAnnotation | Source Codeshared final AuthorsAnnotation The annotation class for the |
DefaultAnnotation | Source Codeshared final DefaultAnnotation The annotation class for the |
DeprecationAnnotation | Source Codeshared final DeprecationAnnotation The annotation class for the |
DocAnnotation | Source Codeshared final DocAnnotation The annotation class for the |
FinalAnnotation | Source Codeshared final FinalAnnotation The annotation class for the |
FormalAnnotation | Source Codeshared final FormalAnnotation The annotation class for the |
LateAnnotation | Source Codeshared final LateAnnotation The annotation class for the |
LicenseAnnotation | Source Codeshared final LicenseAnnotation The annotation class for the |
NativeAnnotation | Source Codeshared final NativeAnnotation The annotation class for the |
OptionalImportAnnotation | Source Codeshared final OptionalImportAnnotation The annotation class for the |
SealedAnnotation | Source Codeshared final SealedAnnotation The annotation class for the |
SeeAnnotation | Source Codeshared final SeeAnnotation The annotation class for the |
SerializableAnnotation | Source Codeshared final SerializableAnnotation The annotation class for the |
SharedAnnotation | Source Codeshared final SharedAnnotation The annotation class for the |
SuppressWarningsAnnotation | Source Codeshared final SuppressWarningsAnnotation The annotation class for the |
TagsAnnotation | Source Codeshared final TagsAnnotation The annotation class for the |
ThrownExceptionAnnotation | Source Codeshared final ThrownExceptionAnnotation The annotation class for the |
VariableAnnotation | Source Codeshared final VariableAnnotation The annotation class for the |
Values | |
empty | Source Codeshared empty empty A sequence with no elements, abbreviated By: Tako Schotanus |
emptyIterator | Source Codeshared emptyIterator emptyIterator An iterator that returns no elements. |
emptyMap | Source Codeshared emptyMap emptyMap An immutable |
emptySet | Source Codeshared emptySet emptySet An immutable |
equal | Source Codeshared equal equal The value is exactly equal to the given value. |
false | Source Codeshared false false A value representing falsity in Boolean logic. |
finished | Source Codeshared finished finished |
infinity | Source Codeshared Float infinity An instance of Note that any floating-point computation that results in a
positive value too large to be represented as a |
language | Source Codeshared language language Contains information about the Ceylon language version. See also process , runtime , system , operatingSystem |
larger | Source Codeshared larger larger The value is larger than the given value. |
nothing | Source Codeshared Nothing nothing A value getter of type (This is most useful for tool-generated implementations of
Throws
|
null | Source Codeshared null null The null value. By: Gavin |
operatingSystem | Source Codeshared operatingSystem operatingSystem |
process | Source Codeshared process process Represents the current process (instance of the virtual machine). By: Gavin, Tako See also language , runtime , system , operatingSystem |
runtime | Source Codeshared runtime runtime Represents the machine and virtual machine on which the current process is executing. Holds information about runtime name, version and about inherent limitations like minimum/maximum values that can be represented by the runtime. See also process , language , system , operatingSystem |
smaller | Source Codeshared smaller smaller The value is smaller than the given value. |
system | Source Codeshared system system Represents the system on which the current process is executing. Holds information about system time and locale. See also process , runtime , language , operatingSystem |
true | Source Codeshared true true A value representing truth in Boolean logic. |
Functions | |
and | Source Codeshared Boolean and<in Value>(Boolean(Value) p, Boolean(Value) q)(Value val) Returns a function which is the logical conjunction of the given predicate functions. Parameters:
|
any | Source Codeshared Boolean any({Boolean*} values) Determines if any one of the given boolean values
(usually a comprehension) is Boolean anyNegative = any { for (x in xs) x<0.0 }; If there are no boolean values, return See also every() , Iterable.any() |
anyPair | Source Codeshared Boolean anyPair<First, Second>(Boolean selecting(First first, Second second), {First*} firstIterable, {Second*} secondIterable) Given two streams, return For any given streams anyPair(p, xs, ys) == zipPairs(xs, ys).any(unflatten(p)) See also everyPair() |
apply | Source Codeshared Return apply<Return, Args>(Return(*Args) f, Args args) Applies an arbitrary For example, given the following argument tuple: [Boolean(Character), Boolean, Boolean] tuple = [Character.whitespace, true, false]; We can apply String string = ... ; {String*} strings = apply(string.split, tuple); Application may be abbreviated using the spread operator: String string = ... ; {String*} strings = string.split(*tuple) In practice, this behaves as if the string.split(Character.whitespace, true, false) See also unflatten() |
arrayOfSize | Source Codeshared Array<Element> arrayOfSize<Element>(Integer size, Element element) Deprecated: Use Create an array of the specified Parameters:
Throws
See also runtime.maxArraySize |
byDecreasing | Source Codeshared Comparison byDecreasing<Element, Value>(Value comparable(Element e))(Element x, Element y) Produces a comparator function which orders elements in
decreasing order according to the "Hello World!".sort(byDecreasing(Character.lowercased)) This function is intended for use with See also byIncreasing() , decreasing() , Iterable.max() , Iterable.sort() |
byIncreasing | Source Codeshared Comparison byIncreasing<Element, Value>(Value comparable(Element e))(Element x, Element y) Produces a comparator function which orders elements in
increasing order according to the "Hello World!".sort(byIncreasing(Character.lowercased)) This function is intended for use with See also byDecreasing() , increasing() , Iterable.max() , Iterable.sort() |
byItem | Source Codeshared Comparison byItem<Item>(Comparison comparing(Item x, Item y))(Object->Item x, Object->Item y) A comparator for value sortedEntries = map.sort(byItem(byIncreasing(String.lowercased))); This function is intended for use with See also byKey() |
byKey | Source Codeshared Comparison byKey<Key>(Comparison comparing(Key x, Key y))(Key->Object x, Key->Object y) A comparator for value sortedEntries = map.sort(byKey(byIncreasing(String.lowercased))); This function is intended for use with See also byItem() |
className | Source Codeshared String className(Anything obj) Return the name of the concrete class of the given object,
in a format native to the virtual machine. For example,
To obtain a platform-independent class name, use the
type(1).declaration.qualifiedName evaluates to See also type() |
comparing | Source Codeshared Comparison comparing<in Value>(Comparison(Value, Value)[] comparators)(Value x, Value y) A single comparator function which delegates to each of the
given comparator functions in turn,
returning the first result of Consider the following type: class Person(shared Integer age, shared String name) {} A stream of people.sort(comparing(byDecreasing(Person.age), byIncreasing(Person.name))) If no This function is intended for use with See also byDecreasing() , byIncreasing() , Iterable.max() , Iterable.sort() |
compose | Source Codeshared X(*Args) compose<X, Y, Args>(X(Y) x, Y(*Args) y) Given a function with return type For any such functions compose(g,f)(*args)==g(f(*args)) for every possible argument tuple |
concatenate | Source Codeshared Element[] concatenate<Element>({Element*}[] iterables) Given zero or more argument streams, return a new sequence containing all elements of every given stream. The elements of the resulting stream are ordered first according to the stream in which they occur, and then according to where they occur in that stream. If there are no arguments, or if none of the argument streams contain any elements, return the empty sequence. For example, the expression concatenate(1..3, [0.0], {"hello", "world"}) results in the sequence Parameters:
See also expand() , Iterable.chain() , Sequential.append() |
corresponding | Source Codeshared Boolean corresponding<First, Second>({First*} firstIterable, {Second*} secondIterable, Boolean comparing(First first, Second second) = ...) Compares corresponding elements of the given streams using
the given binary predicate function. Two
elements are considered corresponding if they occupy the
same position in their respective streams. Returns
Returns For example: corresponding({ 1, 2, 3, 4 }, 1:4) and: corresponding({ 1, 2, 3, 4 }, "1234", (Integer i, Character c) => i.string==c.string) both evaluate to Parameters:
See also everyPair() |
count | Source Codeshared Integer count({Boolean*} values) A count of the number of Integer negatives = count { for (x in xs) x<0.0 }; See also Iterable.count() |
curry | Source Codeshared Return(*Rest) curry<Return, Argument, First, Rest>(Callable<Return,Tuple<Argument,First,Rest>> f)(First first) Curries a function, returning a function with two parameter lists, given a function with at least one parameter. The first parameter list of the returned function has just the first parameter of the original function, and the second parameter list has the remaining parameters. That is, if |
decreasing | Source Codeshared Comparison decreasing<Element>(Element x, Element y) A comparator function which orders elements in decreasing natural order. "Hello World!".sort(decreasing) This function is intended for use with See also increasing() , byDecreasing() , Iterable.max() , Iterable.sort() |
decreasingItem | Source Codeshared Comparison decreasingItem<Item>(Object->Item x, Object->Item y) A comparator function which orders entries by decreasing natural order of their items. This function is intended for use with |
decreasingKey | Source Codeshared Comparison decreasingKey<Key>(Key->Anything x, Key->Anything y) A comparator function which orders entries by decreasing natural order of their keys. This function is intended for use with |
emptyOrSingleton | Source Codeshared []|[Element&Object] emptyOrSingleton<Element>(Element element) A singleton For example, flat mapping
{ "1.23", "foo", "5.67", "-1", "" } .map(parseFloat) .flatMap(emptyOrSingleton<Float?>) produces the stream: { 1.23, 5.67, -1.0 } |
every | Source Codeshared Boolean every({Boolean*} values) Determines if every one of the given boolean values
(usually a comprehension) is Boolean allPositive = every { for (x in xs) x>0.0 }; If there are no boolean values, return See also any() , Iterable.every() |
everyPair | Source Codeshared Boolean everyPair<First, Second>(Boolean selecting(First first, Second second), {First*} firstIterable, {Second*} secondIterable) Given two streams, return For any given streams everyPair(p, xs, ys) == zipPairs(xs, ys).every(unflatten(p)) See also corresponding() , anyPair() |
expand | Source Codeshared Iterable<Element,OuterAbsent|InnerAbsent> expand<Element, OuterAbsent, InnerAbsent>(Iterable<Iterable<Element,InnerAbsent>,OuterAbsent> iterables) Given a stream whose elements are also streams, return a new stream with all elements of every nested stream. If there are no nested streams, or if all of the nested streams are empty, return an empty stream. For example, the expression expand { 1..3, {5}, "hi" } results in the stream See also Iterable.flatMap() , concatenate() , Iterable.chain() |
findPair | Source Codeshared [First, Second]? findPair<First, Second>(Boolean selecting(First first, Second second), {First*} firstIterable, {Second*} secondIterable) Given two streams, return the first pair of elements in the given streams that satisfies the given binary predicate function, or null if no pair of elements satisfies the predicate. If one of the streams is longer than the other, simply ignore additional elements of the longer stream with no pair in the other stream. For any given streams findPair(p, xs, ys) == zipPairs(xs, ys).find(unflatten(p)) |
flatten | Source Codeshared Return(*Args) flatten<Return, Args>(Return tupleFunction(Args tuple)) Given a function with a single parameter of tuple type
That is, if In the case of a function whose parameter type is a sequence type or unterminated tuple type, the returned function is variadic:
See also unflatten() |
foldPairs | Source Codeshared Result foldPairs<Result, First, Second>(Result initial, Result accumulating(Result partial, First first, Second second), {First*} firstIterable, {Second*} secondIterable) Given two streams, return the result of applying the given accumulating function to each pair of elements of the given streams in turn. If one of the streams is longer than the other, simply ignore additional elements of the longer stream with no pair in the other stream. For any given streams foldPairs(z, f, xs, ys) == zipPairs(xs, ys).fold(z)(unflatten(f)) |
forItem | Source Codeshared Result forItem<Item, Result>(Result resulting(Item item))(Object->Item entry) |
forKey | Source Codeshared Result forKey<Key, Result>(Result resulting(Key key))(Key->Anything entry) |
formatFloat | Source Codeshared String formatFloat(Float float, Integer minDecimalPlaces = 1, Integer maxDecimalPlaces = ...) The string decimal representation of the given
floating point number. If the given number is
negative, the string representation will
begin with The number of decimal places following the decimal point is
controlled by the parameters For example:
Finally:
This function never produces a representation involving scientific notation. Parameters:
See also formatInteger() , parseFloat() |
formatInteger | Source Codeshared String formatInteger(Integer integer, Integer radix = ...) The string representation of the given For example:
Parameters:
Throws
See also formatFloat() , parseInteger() |
identical | Source Codeshared Boolean identical(Identifiable x, Identifiable y) Determine if the arguments are Parameters:
See also identityHash() |
identity | Source Codeshared Value identity<Value>(Value argument) The identity function that always returns its argument. |
identityHash | Source Codeshared Integer identityHash(Identifiable identifiable) Return the system-defined identity hash value of the given value. This hash value is consistent with identity equality. See also identical() |
increasing | Source Codeshared Comparison increasing<Element>(Element x, Element y) A comparator function which orders elements in increasing natural order. "Hello World!".sort(increasing) This function is intended for use with See also decreasing() , byIncreasing() , Iterable.max() , Iterable.sort() |
increasingItem | Source Codeshared Comparison increasingItem<Item>(Object->Item x, Object->Item y) A comparator function which orders entries by increasing natural order of their items. This function is intended for use with |
increasingKey | Source Codeshared Comparison increasingKey<Key>(Key->Anything x, Key->Anything y) A comparator function which orders entries by increasing natural order of their keys. This function is intended for use with |
interleave | Source Codeshared Iterable<Element,Absent> interleave<Element, Absent>([Iterable<Element,Absent>+] iterables) Given one or more argument streams, return a stream containing elements of the given streams. The elements are ordered first according to their position in the argument stream, and then according to the stream in which they occur. The resulting stream contains exactly the same number of elements from each stream. For example, the expression interleave(1..5, "-+".cycled) results in the stream
See also Iterable.interpose() |
largest | Source Codeshared Element largest<Element>(Element x, Element y) Given two See also Comparable , smallest() , max() |
loop | Source Codeshared {Element+} loop<Element>(Element first)(Element|Finished next(Element element)) Produces the stream that results from repeated
application of the given function to the given
For example: loop(0)(2.plus).takeWhile(10.largerThan) produces the stream Parameters:
|
map | Source Codeshared Map<Key,Item> map<Key, Item>({<Key->Item>*} stream, Item choosing(Item earlier, Item later) = ...) Create a new immutable For example: map { 1->"hello", 2->"goodbye" } produces the map This is an eager operation and the resulting map does not
reflect changes to the given |
mapPairs | Source Codeshared Iterable<Result,FirstAbsent|SecondAbsent> mapPairs<Result, First, Second, FirstAbsent, SecondAbsent>(Result collecting(First first, Second second), Iterable<First,FirstAbsent> firstIterable, Iterable<Second,SecondAbsent> secondIterable) Given two streams, form a new stream by applying a binary mapping function to pairs of elements in the given streams. If one of the streams is longer than the other, simply ignore additional elements of the longer stream with no pair in the other stream. The length of the resulting stream is the length of the shorter of the two given streams. For any given streams mapPairs(f, xs, ys) == zipPairs(xs, ys).map(unflatten(f)) For example the expression mapPairs((Float x, Float y) => (x^2+y^2)^0.5, {1.0, 2.0, 1.0}, {1.0, 1.0, 2.0}) evaluates to the stream |
max | Source Codeshared Absent|Value max<Value, Absent>(Iterable<Value,Absent> values) Given a stream of For any nonempty stream Note that See also Comparable , min() , largest() , Iterable.max() |
measure | Source Codeshared Range<Element>|[] measure<Element>(Element first, Integer size) Produces a More precisely, if The measure operator for (i in start:size) { ... } for (char in '0':10) { ... } The measure operator accepts the first index and size of the range: 0:5 // [0, 1, 2, 3, 4] If the size is nonpositive, the range is empty: 0:0 // [] 5:0 // [] 0:-5 // [] |
min | Source Codeshared Absent|Value min<Value, Absent>(Iterable<Value,Absent> values) Given a stream of For any nonempty stream See also Comparable , max() , smallest() |
noop | Source Codeshared void noop(Anything[] arguments) A |
not | Source Codeshared Boolean not<in Value>(Boolean(Value) p)(Value val) Returns a function which is the logical negation of the given predicate function. Parameters:
|
or | Source Codeshared Boolean or<in Value>(Boolean(Value) p, Boolean(Value) q)(Value val) Returns a function which is the logical disjunction of the given predicate functions. Parameters:
|
parseBoolean | Source Codeshared Boolean? parseBoolean(String string) The Recognized values are |
parseFloat | Source Codeshared Float? parseFloat(String string) The If the given string representation contains more digits
than can be represented by a The syntax accepted by this method is the same as the
syntax for a See also formatFloat() , parseInteger() |
parseInteger | Source Codeshared Integer? parseInteger(String string, Integer radix = ...) The The syntax accepted by this function is the same as the
syntax for an The given Parameters:
Throws
See also formatInteger() , parseFloat() |
plus | Source Codeshared Value plus<Value>(Value x, Value y) |
print | Source Codeshared void print(Anything val) Print a line to the standard output of the virtual machine
process, printing the given value's This function is a shortcut for: process.writeLine(line?.string else "<null>") and is intended mainly for debugging purposes. By: Gavin See also process.writeLine() |
printAll | Source Codeshared void printAll({Anything*} values, String separator = ...) Print multiple values to the standard output of the virtual machine process as a single line of text, separated by a given character sequence. Parameters:
By: Gavin See also process.write() |
printStackTrace | Source Codeshared void printStackTrace(Throwable exception, void write(String string) = ...) Print the stack trace of the given Parameters:
|
product | Source Codeshared Value product<Value>({Value+} values) Given a nonempty stream of {Float+} values = ... ; Float result = product(values); For the case of a possibly-empty stream, form a nonempty stream starting with the unit element (the multiplicative identity). {Float*} values = ... ; Float result = product { 1.0, *values }; See also sum() |
sequence | Source Codeshared [Element+]|Absent sequence<Element, Absent = Null>(Iterable<Element,Absent> elements) A nonempty sequence of the given [Element*] sequenceOfElements = sequence(elements) else []; By: Gavin See also Iterable.sequence() |
set | Source Codeshared Set<Element> set<Element>({Element*} stream, Element choosing(Element earlier, Element later) = ...) Create a new immutable For example: set { 0, 1, 1, 2, 3, 3, 3 } produces the set This is an eager operation and the resulting set does not
reflect changes to the given Parameters: See also Iterable.distinct |
shuffle | Source Codeshared Result(*FirstArgs)(*SecondArgs) shuffle<Result, FirstArgs, SecondArgs>(Result(*SecondArgs)(*FirstArgs) f) Given a function with two parameter lists, return a function with the order of the argument lists reversed. The parameter lists may have any number of parameters. That is, if This function is often used in conjunction with See also curry() |
smallest | Source Codeshared Element smallest<Element>(Element x, Element y) Given two See also Comparable , largest() , min() |
sort | Source Codeshared Element[] sort<Element>({Element*} elements) Sort the given elements according to their natural order, returning a new sequence. Note that See also Comparable , Iterable.sort() |
span | Source Codeshared Range<Element> span<Element>(Element first, Element last) Produces a
More precisely, if
For a linear enumerable type, a range is either increasing or decreasing:
The direction of the range depends upon the sign of the
offset of
A range for a recursive enumerable type is always increasing. The span operator for (i in min..max) { ... } if (char in 'A'..'Z') { ... } The span operator accepts the first and last values of the range. It may produce an increasing range: 0..5 // [0, 1, 2, 3, 4, 5] 0..0 // [0] Or it may produce a decreasing range: 5..0 // [5, 4, 3, 2, 1, 0] 0..-5 // [0, -1, -2, -3, -4, -5] |
sum | Source Codeshared Value sum<Value>({Value+} values) Given a nonempty stream of {Float+} values = ... ; Float total = sum(values); For the case of a possibly-empty stream, form a nonempty stream starting with the zero element (the additive identity). {Float*} values = ... ; Float total = sum { 0.0, *values }; See also product() |
times | Source Codeshared Value times<Value>(Value x, Value y) |
uncurry | Source Codeshared Callable<Return,Tuple<Argument,First,Rest>> uncurry<Return, Argument, First, Rest>(Return(*Rest) f(First first)) Uncurries a function, returning a function with one parameter list, given a function with two parameter lists, where the first parameter list has exactly one parameter. The parameter list of the returned function has the parameter of the first parameter list of the original function, followed by all parameters of the second parameter list. That is, if |
unflatten | Source Codeshared Return unflatten<Return, Args>(Return(*Args) flatFunction)(Args args) Given a function with parameter types That is, if In the case of a variadic function, the returned function has a single parameter whose type is a sequence type or unterminated tuple type:
See also flatten() |
unzip | Source Codeshared [Iterable<Head,Absent>, Iterable<Tail,Absent>] unzip<Element, Head, Tail, Absent>(Iterable<Tuple<Element|Head,Head,Tail>,Absent> tuples) Given a stream of tuples, return two streams. The first stream produces the first elements of the given tuples, and the second stream produces the remaining elements of the given tuples. Thus: tuples[i] == [unzip(tuples)[0][i], *unzip(tuples)[1][i]] |
unzipEntries | Source Codeshared [Iterable<Key,Absent>, Iterable<Item,Absent>] unzipEntries<Key, Item, Absent>(Iterable<Key->Item,Absent> entries) Given a stream of entries, return two streams. The first stream produces the keys of the given entries, and the second stream produces the items of the given entries. Thus: entries[i] == unzipEntries(entries)[0][i] -> unzipEntries(entries)[1][i] |
unzipPairs | Source Codeshared [Iterable<First,Absent>, Iterable<Second,Absent>] unzipPairs<First, Second, Absent>(Iterable<[First, Second],Absent> pairs) Given a stream of pairs, return two streams. The first stream produces the first elements of the given pairs, and the second stream produces the second elements of the given pairs. Thus: pairs[i] == [unzipPairs(pairs)[0][i], unzipPairs(pairs)[1][i]] |
zip | Source Codeshared Iterable<Tuple<Element|Head,Head,Tail>,HeadAbsent|TailAbsent> zip<Element, Head, Tail, HeadAbsent, TailAbsent>(Iterable<Head,HeadAbsent> heads, Iterable<Tail,TailAbsent> tails) Given a stream of values, and a stream of tuples, produce a new stream of tuples formed by prepending the values in the first stream to the tuples in the second stream. The length of the resulting stream is the length of the shorter of the two given streams. Thus: zip(heads, tails)[i] == [heads[i], *tails[i]] for every |
zipEntries | Source Codeshared Iterable<Key->Item,KeyAbsent|ItemAbsent> zipEntries<Key, Item, KeyAbsent, ItemAbsent>(Iterable<Key,KeyAbsent> keys, Iterable<Item,ItemAbsent> items) Given two streams, form a new stream consisting of all entries where, for any given index in the resulting stream, the key of the entry is the element occurring at the same index in the first stream, and the item is the element occurring at the same index in the second stream. The length of the resulting stream is the length of the shorter of the two given streams. Thus: zipEntries(keys, items)[i] == keys[i] -> items[i] for every |
zipPairs | Source Codeshared Iterable<[First, Second],FirstAbsent|SecondAbsent> zipPairs<First, Second, FirstAbsent, SecondAbsent>(Iterable<First,FirstAbsent> firstElements, Iterable<Second,SecondAbsent> secondElements) Given two streams, form a new stream consisting of all pairs where, for any given index in the resulting stream, the first element of the pair is the element occurring at the same index in the first stream, and the second element of the pair is the element occurring at the same index in the second stream. The length of the resulting stream is the length of the shorter of the two given streams. Thus: zipPairs(xs, ys)[i] == [xs[i], ys[i]] for every |
Interfaces | |
Annotated | Source Codeshared Annotated A program element that can be annotated. |
Annotation | Source Codeshared Annotation The supertype of all annotation classes. Annotation classesAn annotation class must satisfy "An annotation class." final annotation class Example(shared String description) satisfies Annotation {} Annotation classes which satisfy Each initializer parameter of an annotation class must have one of the following types:
An initializer parameter of an annotation class may be variadic or defaulted. Annotation constructorsAn annotation constructor is simply a top level
function, annotated with "An annotation constructor." annotation Example example(String description="") => Example(description); Each parameter of an annotation constructor must have one of the following types:
A parameter of an annotation constructor may be variadic or defaulted. The constructor must simply instantiate and return the annotation class, and there are strict rules about the arguments to the instantiation. A given annotation class can have multiple annotation constructors. |
Binary | Source Codeshared Binary<Other> Abstraction of types that are conceptually a sequence of
bits, and may be the subject of bitwise operations. A bit
is a |
Callable | Source Codeshared out Return(*in Arguments) A reference to a function. The type arguments encode the
Return of the function along with its
Arguments. The parameter types are
represented by a tuple type. Functions declared For example, the type of the anonymous function
Callable<Float, [Float,Integer]> which we usually abbreviate to Likewise, the type of the function reference Callable<Float, [Float,Float]> which we abbreviate as A variadic function is represented using an unterminated
tuple type. For example, the type of the function reference
Callable<Object[], [{Object*}*]> which we usually abbreviate A function with defaulted parameters is represented using
a union type. For example, the type of the method reference
Callable<Anything, [String]|[]> which we usually abbreviate Finally, any type of form Any instance of Float(Float,Float) add = plus<Float>; value four = add(2.0, 2.0); or by supplying a tuple containing the arguments: Float(Float,Float) add = plus<Float>; [Float,Float] twoAndTwo = [2.0, 2.0]; value four = add(*twoAndTwo); The type of the tuple must be assignable to the type
argument of There is no reasonable and computationally decidable
definition of value equality for a
function reference. Therefore, the This interface may not be implemented by user-written code. |
Category | Source Codeshared Category<in Element = Object> Abstract supertype of objects that contain other values,
called elements, where it is possible to efficiently
determine if a given value is an element. A
The if (69 in 0..100) { ... } assert (key->item in { for (n in 0..100) n.string->n**2 }); An object may be a if ("hello" in "hello world") { ... } assert ('.' in string); Every meaningful Since Note that even though |
Collection | Source Codeshared Collection<out Element = Anything> An iterable collection of elements of finite A A All |
Comparable | Source Codeshared Comparable<in Other> The general contract for values whose magnitude can be
compared. If a type assert (x>=0.0); A ternary comparison is useful for asserting lower and upper bounds. assert (0.0<=x<1.0); Finally, the compare operator switch (x<=>y) case (equal) { print("same same"); } case (smaller) { print("x smaller"); } case (larger) { print("y smaller"); } The total order of a type must be consistent with the definition of equality for the type. That is, there are three mutually exclusive possibilities:
(These possibilities are expressed by the enumerated
instances The order imposed by
|
ConstrainedAnnotation | Source Codeshared ConstrainedAnnotation<out Value = Annotation,out Values = Anything,in ProgramElement = Nothing,out Type = Anything> An annotation constrained to appear only on certain program elements, and only with certain values. This interface should never be satisfied directly by any
annotation type. Instead, either The type parameters encode information about the annotation type and its constraints:
|
Correspondence | Source Codeshared Correspondence<in Key,out Item = Anything> Abstract supertype of objects which associate values with
keys. A
The item corresponding to a given key may be obtained from
a value bg = settings["backgroundColor"] else white; The |
Destroyable | Source Codeshared Destroyable Abstract supertype of resources which are created at the
beginning of a try (tx = Transaction()) { ... }
|
Empty | Source Codeshared Empty A sequence with no elements. The type [] none = []; (Whether the syntax |
Enumerable | Source Codeshared Enumerable<Other> Abstraction of ordinal types whose values may
be used as endpoints of a An
The offset function must satisfy:
The neighbour function must satisfy:
Of course, it follows that:
An enumerable type may be linear or recursive. If
Otherwise,
A range of values of an enumerable type may be specified using:
|
Exponentiable | Source Codeshared Exponentiable<This,Other> Abstraction of numeric types that may be raised
to a power using the exponentiation operator function exp(Float x) => e^x; The exponentiation operation should obey the usual index laws, including:
where Note that in general, the type of the exponent may be
different to the numeric type which is exponentiated. For
example, a |
Identifiable | Source Codeshared Identifiable The abstract supertype of all types with a well-defined
notion of identity. Values of type For the sake of convenience, this interface defines a default implementation of value equality equivalent to identity. Of course, subtypes are encouraged to refine this implementation. |
Integral | Source Codeshared Integral<Other> Abstraction of integral numeric types. That is, types
with no fractional part, including The division operation for integral numeric types results
in a remainder. Therefore, integral numeric types have
an operation, denoted by the remainder
operator if (n%2==0) { print("Even!"); } Division and the remainder operation should satisfy:
for any instance All // Iterate from 0 to 100 inclusive for (i in 0..100) { print("The square of ``i`` is ``i^2``"); } // Iterate all indices of the array, // from 0 to array.size-1 for (i in 0:array.size) { print(array[i]); } |
Invertible | Source Codeshared Invertible<Other> Abstraction of additive numeric types which
support a unary operation Integer negativeOne = -1; Float delta = x-y; A concrete class that implements this interface should be a
mathematical group. That is, it should have an additive
identity, denoted
Subtraction must be defined so that it is consistent with the additive inverse:
|
Iterable | Source Codeshared Iterable<out Element = Anything,out Absent = Null> Abstract supertype of categories whose elements may be iterated. Iterable categories are often called streams. A stream need not be finite, but its elements must be countable. That is, for any given element of the stream, every iterator of the stream must eventually return the element, even if the iterator itself is not exhaustible. A stream may have null elements. That is, an iterator for
the stream may produce the value A given stream might not have a well-defined order, and
so the order in which elements are produced by the
stream's iterator may not be stable. That is, the order
may be different for two different iterators of the
stream. However, a stream has a well-defined set of
elements, and any two iterators for an immutable finite
stream should eventually return the same elements.
Furthermore, any two iterators for an immutable finite
stream should eventually return exactly the same number
of elements, which must be the A given stream may not be finite, in which case an
iterator for the stream is never exhaustible, and certain
operations of this interface either never terminate or
result in an The type A value list in braces produces a new instance of
{String+} words = { "hello", "world" }; An instance of for (c in "hello world") { ... } Comprehensions provide a convenient syntax for transforming streams: {Integer+} lengths = { for (w in words) w.size }; The {Integer+} lengths = words*.size;
Lazy operations are generally preferred, because they can be efficiently chained. For example: string.filter((c) => c.letter||c.digit) .map(Character.uppercased) is much less expensive than: string.select((c) => c.letter||c.digit) .collect(Character.uppercased) Furthermore, it is always easy to produce a new immutable iterable object given the view produced by a lazy operation. For example: [ *string.filter((c) => c.letter||c.digit) .map(Character.uppercased) ] However, there are certain scenarios where an eager operation is more useful, more convenient, or no more expensive than a lazy operation, including:
Certain operations come in both lazy and eager flavors, for example:
Lazy operations normally return an instance of There is no meaningful generic definition of equality for
streams. For some streams—for example,
To compare two streams, taking order into account, use
the function {Float*} xs = ... ; {Float*} ys = ... ; Boolean same = corresponding(xs, ys); |
Iterator | Source Codeshared Iterator<out Element> Produces the elements of an class IntegerIterable(Integer min, Integer max) satisfies {Integer+} { iterator() => object satisfies Iterator<Integer> { variable value i = min; next() => i<=max then i++ else finished; }; } An iterator is exhausted when |
List | Source Codeshared List<out Element = Anything> A collection in which every element has a unique
non-negative integer index. The elements of a nonempty
list are indexed starting with
Thus, the range of indexes of the list is formed by the
expression A Every list has a well-defined and stable iteration order.
An Direct access to a list element by index produces a value
of optional type. The following idiom may be used instead
of upfront bounds-checking, as long as the list element
type is a non- if (exists char = "hello world"[index]) { //do something with char } else { //out of bounds } When an algorithm guarantees that a list contains a given index, the following idiom may be used: assert (exists char = "hello world"[index]); //do something with char To iterate the indices of a for (i->char in "hello world".indexed) { ... } Strings, sequences,
tuples, and arrays are all |
Map | Source Codeshared Map<out Key = Object,out Item = Anything> A collection which maps keys to items, where a key
can map to at most one item. Each such mapping may be
represented by an A A new value settings = map { "lang"->"en_AU", "loc"->"ES" }; The The presence of an entry in a map may be tested using the
if ("lang"->"en_AU" in settings) { ... } The entries of the map may be iterated using for (key->item in settings) { ... } The item for a key may be obtained using the item operator: String lang = settings["lang"] else "en_US"; An implementation of |
Number | Source Codeshared Number<Other> Abstraction of numeric types with a natural
total order, including the built-in numeric
types A
where Not every value commonly considered to be a “number” is
a |
Numeric | Source Codeshared Numeric<Other> Abstraction of numeric types with the usual binary operations:
A concrete class which implements this interface should be a mathematical ring. That is:
It is preferred, but not required, that the class be a mathematical field. That is, in addition to the above:
For numeric types which are not fields, for example,
for any instance For numeric types which are fields, division never produces a remainder, and division should additionally satisfy:
for any instance Some numeric types, for example complex numbers, do not
have a total order. Numeric types with a
total order also satisfy |
Obtainable | Source Codeshared Obtainable Abstract supertype of resources which may be obtained at
the beginning of a Lock lock = ... ; try (lock) { ... }
A class which satisfies |
OptionalAnnotation | Source Codeshared OptionalAnnotation<out Value,in ProgramElement = Annotated,out Type = Anything> An annotation that may occur at most once at a given program element and only on certain program elements. An optional annotation is declared simply by having the
annotation class satisfy final annotation class ExampleClass() satisfies OptionalAnnotation<Example, ClassDeclaration> {} At runtime a |
Ordinal | Source Codeshared Ordinal<out Other> Abstraction of ordinal types, that is, of types where
each instance has a
The increment operator function increment() { count++; } Many ordinal types have a total order. If an ordinal type has a total order, then it should satisfy:
An ordinal enumerated type
|
Ranged | Source Codeshared Ranged<in Index,out Element,out Subrange> Abstract supertype of ranged streams mapping a range of
discrete indices to elements of the stream, and supporting
operations that produce a subrange of indexed elements. The
type parameter Often, in a The span operator accepts the first and last indices of the subrange. print("hello world"[0..4]); //prints "hello" print("hello world"[6..6]); //prints "w" If the last index is smaller than the first index, the subrange is reversed. print("hello world"[4..0]); //prints "olleh" If the range of indices identified by the first and last indices is outside the range of indices of this object, an empty subrange is produced. print("hello world"[-5..-1]); //prints "" print("hello world"[11..11]); //prints "" The first index may be omitted, implying that the subrange
extends forward from the smallest possible index (in this
case print("hello world"[...4]) //prints "hello" If the first index is before the first index of this object, the first index of the object is used. print("hello world"[-5...]); //prints "hello world" The last index may be omitted, implying that the subrange
extends forward from the given index to the largest
possible index (in this case print("hello world"[6...]) //prints "world" If the last index is after the last index of this object, an empty subrange is produced. (A reversed subrange is never produced.) print("hello world"[11...]); //prints "" The measure operator accepts the first index and maximum length of the subrange. print("hello world"[6:5]) //prints "world" print("hello world"[6:0]) //prints "" If the length is nonpositive, the subrange is empty. If the range of indices identified by the first index and length is outside the range of indices of this object, an empty subrange is produced. (A reversed subrange is never produced.) print("hello world"[-3:3]) //prints "" print("hello world"[11:3]) //prints "" print("hello world"[6:-3]) //prints "" The span and measure operations must be consistent. That is,
for every pair of indices
|
Resource | Source Codeshared Resource A file packaged within a module. A The resource file itself must be placed in a resource directory at compilation time, in a subdirectory corresponding to the module to which the resource belongs. The compiler is responsible for packaging the resource file in a location accessible to the program at runtime:
Suppose the following code occurs in a module named
assert (exists resource = `module`.resourceByPath("file.txt")); print(resource.textContent()); Then the resource named Paths with no leading assert (exists resource = `module`.resourceByPath("/com/redhat/example/file.txt")); print(resource.textContent()); |
Scalable | Source Codeshared Scalable<in Scale,out Value> Abstract supertype of types that support scaling by a
numeric factor. Examples of such types include vectors and
matrices. The scale operator Vector scaled = 2.0 ** Vector(x,y,z); Concrete classes which implement this interface should satisfy:
where Concrete classes which implement this interface are
encouraged to also satisfy
Concrete classes which implement this interface and which
also satisfy
The Scale must be a numeric
type, but is not required to be |
SearchableList | Source Codeshared SearchableList<Element> A
Occurrences and inclusions are identified by a list index at which the value or sublist of values occurs in the list. In the case of an inclusion, it is the index of the first matching value from the sublist. Inclusions may overlap. For example: "yoyoyoyoyo".inclusions("yoy") produces the stream An empty list is considered to be included at every index,
including the index "hello".inclusions("") produces the stream In particular:
|
Sequence | Source Codeshared Sequence<out Element = Anything> A nonempty, immutable sequence of values. The type
Given a possibly-empty sequence of type [Integer*] nums = ... ; if (nonempty nums) { Integer first = nums.first; Integer max = max(nums); [Integer+] squares = nums.collect((Integer i) => i**2)); [Integer+] sorted = nums.sort(byIncreasing((Integer i) => i)); } Operations like
|
SequencedAnnotation | Source Codeshared SequencedAnnotation<out Value,in ProgramElement = Annotated,out Type = Anything> An annotation that may occur multiple times at a given program element, and only on certain program elemenets. A sequenced annotation is declared simply by having the
annotation class satisfy alias ExecutableDeclaration => ClassOrInterfaceDeclaration|FunctionDeclaration; "Documents a pattern in which the annotated element particpates." shared final annotation class Pattern(String name) satisfies SequencedAnnotation<Pattern, ExecutableDeclaration> {} At runtime a |
Sequential | Source Codeshared Sequential<out Element = Anything> A possibly-empty, immutable sequence of values. The type
|
Set | Source Codeshared Set<out Element = Object> A collection in which each distinct element occurs at most once. Two non-identical values are considered distinct only if they are unequal, according to their own definition of value equality. A A new value words = set { "hello", "world" }; value greetings = set { "hello", "goodbye", "hola", "adios" }; The Sets may be the subject of the binary union, intersection,
and complement operators value greetingsInWords = words & greetings; value allWords = words | greetings; An implementation of |
Summable | Source Codeshared Summable<Other> Abstraction of types which support a binary addition
operator Integer next = current + 1; String helloWorld = "hello" + " " + "world"; A concrete class that implements this interface should be a mathematical semigroup. That is, the addition operation should be associative, satisfying:
A
For any monoid, the addition operation must satisfy:
|
Usable | Source Codeshared Usable Abstract supertype of resources whose lifecyle may be
managed by the |
Classes | |
Anything | Source Codeshared abstract Anything The abstract supertype of all types. A value of type
Note that the bottom type |
Array | Source Codeshared final Array<Element> A fixed-sized array of mutable elements. An empty array
is an array of value array = Array { "hello", "world" }; value ints = Array.ofSize(1k, 0); Arrays are mutable. Any element of an array may be set to a new value. value array = Array { "hello", "world" }; array.set(0, "goodbye"); Arrays are lists and support all operations inherited from
This class is provided primarily to support interoperation with Java, and for some performance-critical low-level programming tasks. |
ArraySequence | Source Codeshared final ArraySequence<out Element> |
Basic | Source Codeshared abstract Basic The default superclass when no superclass is explicitly
specified using |
Boolean | Source Codeshared abstract Boolean |
Byte | Source Codeshared final Byte An 8-bit byte. A
(-b).signed == -b.signed (-b).unsigned == b.unsigned==0 then 0 else 256 - b.unsigned
254.byte .. 1.byte contains the values
Thus, to compare the magnitude of two bytes, it is
necessary to first convert them to either their
|
Character | Source Codeshared final Character A 32-bit Unicode character. Literal characters may be written between single quotes: ' ' '\n' '\{#03C0}' '\{GREEK SMALL LETTER PI}' Every Integer piCodePoint = '\{GREEK SMALL LETTER PI}'.integer; // #03C0 Character pi = #03C0.character; // GREEK SMALL LETTER PI Characters are value lowerLatinLetters = 'a'..'z'; value upperLatinLetters = 'A':26; Characters have a natural order determined
by their Unicode code points. So, for example, |
Comparison | Source Codeshared abstract Comparison The result of a comparison between two |
Contextual | Source Codeshared Contextual<Element> Stores values local to the current thread of execution meaning that each thread or process that accesses these values get to see their own copy. If the underlying platform does not support threading the practical effect of this class is no different than using a local value. Setting a value is done by creating an instance of
If a function is used to set the value then that value will
be retrieved the moment the try-resource block is entered.
If the same When entering a try-resource block any previous value is stored and then restored at the end of the block so nested try-resource blocks are possible. Retrieving the value is done using An example: Contextual<String> stringValue = Contextual<String>(); Contextual<Integer> intValue = Contextual<Integer>(); try (stringValue.Using("foo"), intValue.Using(system.milliseconds)) { print(stringValue.get()); // prints "foo" print(intValue.get()); // prints the current time in ms try (stringValue.Using("bar")) { print(stringValue.get()); // prints "bar" print(intValue.get()); // prints same number as before } } NB: This example only shows how to use |
Entry | Source Codeshared final Entry<out Key,out Item> A pair containing a key and an associated value called
the item. Used primarily to represent the elements of a
String->Person entry = person.name->person; |
Finished | Source Codeshared abstract Finished The type of the value that indicates that an |
Float | Source Codeshared final Float An IEEE 754 64-bit floating point number. A
Zero is represented by distinct instances In addition, the following special values exist:
As required by the IEEE standard no undefined value is
equal to any other value, nor even to itself. Thus, the
definition of A floating point value with a zero Literal floating point values are written with a decimal point and, optionally, a magnitude or exponent: 1.0 1.0E6 1.0M 1.0E-6 1.0u In the case of a fractional magnitude, the decimal point is optional. Underscores may be used to group digits into groups of three. |
Integer | Source Codeshared final Integer An exact representation of a positive whole number, negative whole number, or zero. The largest and smallest representable values are platform-dependent:
Overflow or loss of precision occurs silently (with no exception raised). An integer is considered equal to its An integer is represented as a sequence of bits. Not all of
the bits in the representation may be addressed by the
methods inherited from
Literal integers may be written in decimal, hexadecimal, or binary notation: 8660 #21D4 $10000111010100 Underscores may be used to group digits: 8660 #21_D4 $10_0001_1101_0100 |
Null | Source Codeshared abstract Null The type of the The String? firstArg = process.arguments.first; if (exists firstArg) { print("hello " + firstArg); } The String name = process.arguments.first else "world"; The Float? diff = x>=y then x-y; The value [firstName, lastName] = let (fullName = process.arguments.first?.trimmed, bits = fullName?.split()?.sequence() else []) [bits[0], bits[1]]; assert (exists firstName, exists lastName); No equivalence relation is defined for |
Object | Source Codeshared abstract Object The abstract supertype of all types representing definite
values. Any two values which are assignable to true == false 1 == "hello world" "hello"+" "+"world" == "hello world" Singleton("hello world") == ["hello world"] However, since A concrete subclass of In extreme cases it is acceptable for two values to be
equal even when they are not instances of the same class.
For example, the |
Range | Source Codeshared abstract Range<Element> A range of adjacent range[index+1].offset(range[index]).magnitude <= 1 A range is always nonempty, containing at least one value.
Thus, it is a A sequence of adjacent values may be represented very efficiently in memory, either:
Furthermore, certain operations are much more efficient than for other lists, assuming that the enumerable type has efficient neighbour and offset functions. The functions |
Singleton | Source Codeshared final Singleton<out Element> A |
String | Source Codeshared final String A string of characters. Each character in the string is a 32-bit Unicode character. The internal UTF-16 encoding is hidden from clients. Literal strings may be written between double quotes: "hello world" "\r\n" "\{#03C0} \{#2248} 3.14159" "\{GREEK SMALL LETTER PI} \{ALMOST EQUAL TO} 3.14159" Alternatively, a verbatim string may be written between tripled double quotes. The empty string, A string is a 'w' in greeting "hello" in greeting Strings are summable: String greeting = "hello" + " " + "world"; They are efficiently iterable: for (char in "hello world") { ... } They are lists of characters: value char = "hello world"[5]; They are ranged: String who = "hello world"[6...]; Note that since It is easy to use comprehensions to transform strings: String { for (s in "hello world") if (s.letter) s.uppercased } Since a |
StringBuilder | Source Codeshared final StringBuilder Builder utility for constructing strings by incrementally appending strings or characters. value builder = StringBuilder(); builder.append("hello"); builder.appendCharacter(' '); builder.append("world"); String hello = builder.string; //hello world |
Tuple | Source Codeshared final Tuple<out Element,out First,out Rest = []> A tuple is a typed linked list. Each instance of
value point = Tuple(0.0, Tuple(0.0, Tuple("origin"))); Float x = point.first; Float y = point.rest.first; String label = point.rest.rest.first; Usually, we abbreviate code involving tuples. [Float,Float,String] point = [0.0, 0.0, "origin"]; Float x = point[0]; Float y = point[1]; String label = point[2]; A list of types enclosed in brackets is an abbreviated
tuple type. An instance of [String,String] words = ["hello", "world"]; The index operator with a literal integer argument is a
shortcut for a chain of evaluations of A terminated tuple type is a tuple where the type of
the last link in the chain is Here, String[] labels = ... ; [Float,Float,String*] point = [0.0, 0.0, *labels]; Float x = point[0]; Float y = point[1]; String? firstLabel = point[2]; String[] allLabels = point[2...]; |
empty | Source Codeshared empty A sequence with no elements, abbreviated |
emptyIterator | Source Codeshared emptyIterator An iterator that returns no elements. |
emptyMap | Source Codeshared emptyMap An immutable |
emptySet | Source Codeshared emptySet An immutable |
equal | Source Codeshared equal The value is exactly equal to the given value. |
false | Source Codeshared false A value representing falsity in Boolean logic. |
finished | Source Codeshared finished A value that indicates that an |
language | Source Codeshared language Contains information about the Ceylon language version. |
larger | Source Codeshared larger The value is larger than the given value. |
null | Source Codeshared null The null value. |
operatingSystem | Source Codeshared operatingSystem Represents the operating system on which the current process is running. |
process | Source Codeshared process Represents the current process (instance of the virtual machine). |
runtime | Source Codeshared runtime Represents the machine and virtual machine on which the current process is executing. Holds information about runtime name, version and about inherent limitations like minimum/maximum values that can be represented by the runtime. |
smaller | Source Codeshared smaller The value is smaller than the given value. |
system | Source Codeshared system Represents the system on which the current process is executing. Holds information about system time and locale. |
true | Source Codeshared true A value representing truth in Boolean logic. |
Exceptions | |
AssertionError | Source Codeshared AssertionError An error that occurs due to an incorrectly written program.
An instance is thrown when an assertion fails, that is,
when a condition in an The assertion "x must be positive" assert (x>0); has almost the same effect as this if (!x>0) { throw AssertionError("x must be positive"); } |
Exception | Source Codeshared Exception The supertype of all unexpected transient failures. An
For example, code that interacts with a relational database
isn't typically written to recover from transaction
rollback or loss of network connectivity. However, these
conditions aren't completely unrecoverable from the point
of view of the program's generic exception handling
infrastructure. Therefore, they are best treated as
A subclass of |
InitializationError | Source Codeshared InitializationError Assertion failure that occurs when a value reference could not be initialized, including when:
|
OverflowException | Source Codeshared OverflowException Thrown when a mathematical operation caused a number to overflow from its bounds, or when a numeric narrowing conversion fails because the number cannot be represented within the bounds of the narrower type. Note that: |
Throwable | Source Codeshared abstract Throwable The abstract supertype of values indicating exceptional
conditions. An exception may be raised using the void tryToDoIt() { if (canDoIt()) { doIt(); } else { throw CantDoIt(); //the Throwable } } try { tryToDoIt(); } catch (CantDoIt e) { e.printStackTrace(); } An instance of
The use of the exceptions facility to manage expected failures, that is, failures that are usually handled by the immediate caller of an operation, is discouraged. Instead, the failure should be represented as a return value of the operation being called. For example, nonexistence of a file should not result in an
exception. Instead, an |