An expression of DynamicLookup type can be unconditionally downcast to
any class type via the postfix '!'. This will allow one to replace
var w : NSWindow = (nsarray[0] as NSWindow)!
with
var w : NSWindow = nsarray[0]!
The current implementation is fairly limited: it only works when the
operand of '!' is an rvalue of type DynamicLookup, and we don't ensure
that the result is a class type. Nonetheless, it cleans up some of
ListMaker nicely.
This is the first client of disjunction constraints, which were added
in r9142.
Swift SVN r9151
This moves trailing closures from expr-postfix up to the level of
expr, and introduces an intermediate level (expr-basic) for places
that need to parse expressions followed by curly braces, such as
if/while/switch/for. Trailing closures are still restricted to occur
after expr-postfix, although the parser itself parses a slightly more
general and then complains if it got more than an expr-postfix.
Swift SVN r5256
Trailing closure syntax allows one to write a closure following any
other postfix expression, which passes the closure to that postfix
expression as an arguments. For example:
sort(fruits) { |lhs, rhs|
print("Comparing \(lhs) to \(rhs)\n")
return lhs > rhs
}
As a temporary limitation to work around the ambiguity with
if foo { ... } { ... }
we require trailing closures to have an explicit parameter list, e.g.,
if foo { || ... } { ... }
Swift SVN r5210