Jun 252014

Getting to grips with Swift. Nice and tidy, especially as it removes a lot of those irritating idiosyncrasies that are annoying in C, C++ and elsewhere! Here are just a few simple language features that have caught my eye…

  • break replaced by fallthrough in switch blocks (there’s no switch in Python)
  • No more pointless end-of-statement ‘;’ (see Python)
  • Assignment no longer returns a value. so ‘if (x = 0)’ is now a compilation error (see Python)
  • Functions can return tuples (see Python)
  • Function parameters can be named (See Python)
  • Numeric overflows now trapped (essential at the assembler-level, now exposed at the language level) (see Python). It’s an exception now, which may not suit everyone, but at least it’s addressing a crucial source of bugs. Incidentally, in Python numbers don’t overflow, they just get bigger until you run out of memory. Try this in your favourite language:-
    >>> x = 1896487364879364782167862198756987315198
    >>> print x + 1
 Posted by at 1:05 pm  Tagged with: