Creation expressions

Sather - Language Specification
Prev | Chapter 7. Basic Expressions | Next

# 7.7. Creation expressions

Example 7-9. Examples:

    #FOO(1,2,3)
    #(1,2,3)
    #FOO
    #

    create_expression ==>
            # [ type_specifier ] [ ( modal_list ) ]

Immutable and reference object creation expressions are a convenient shorthand used for creating new objects and initializing their attributes. A creation expression is a special syntactic sugar for a call on a routine named 'create' with the specified arguments. 'self' is given the default void value described on See void expressions in this call. The type defining the 'create' routine may be explicitly specified as a reference or immutable type. If the type is not explicitly specified, then it is taken to be the declared type of the context in which the call appears (and it must be an immutable or reference type). A type must be specified when it cannot be inferred from context: if the expression appears as the right hand side of a '::=' assignment (See Assignment statements), as a method argument in which overloading resolution would otherwise be ambiguous, or as the left argument of the dot '.' operator (See Method call expressions).

Prev | Home | Next
new expressions | Up | Array creation expressions