3 ms·
<curmudgeon> Assignment using := and string concatenation using adjacency aren't particularly new. </curmudgeon> edit -- further looking through the presenta
by jacques_chester 16y ago
<curmudgeon>
Assignment using := and string concatenation using adjacency aren't particularly new.
</curmudgeon>
edit -- further looking through the presentations ...
They seem to have ditched the 'new' keyword, but not gone as far as having inferred typing which is a pity.
Counter c = Counter();
would be better as
c = Counter();
(edit: ignore this, the local keyword apparently triggers type inference).
:= and = are used to distinguish between assignment to mutable and immutable variables. Is this necessary?
Clever use of syntactic sugar gives it a Lua-like flavour for programmatic generation of markup / UIs.
Use of & and | symbols gives a clever way to assemble interfaces.
When an object "satisfies" (ie "implements") interfaces, it can combine them either as intersections (&) or unions (|) of multiple interfaces.
A few nice features imported from functional programming land include algebraic types and type-safe switches.
A lot of attention paid to the covariance/contravariance tarpit.
- jbellis 16y agoTFA suggests "local c = Counter()" is what you are looking for.
- jacques_chester 16y agoYou're right.
- fleitz 16y agoConstructors are stupid and violate one of the principle ideas behind OO which is separation of concerns. What initializes a data structure should not care how the data structure was allocated. It's two functions one () -> T and T -> T allow them to be first class citizens. If you want to combine them use a static method that simply invokes the initializer after the allocator (which is how it works anyway, and how new is implemented in both Ruby and Obj-C). And it's not like it solves any real problems as it's perfectly alright to have uninitialized and incorrectly initialized objects with current constructors.