Hacker News new | ask | show | jobs
by himom 2927 days ago
Technically, any Turing-complete language can be mapped to any other Turing complete language, so it’s possible to have non-trivial syntatic sugar do anything. (Use brainfuck as IR, lol.) >:) But yeah, SS is more like:

    ++x; // x = x + 1 
Nifty syntax

    &:foo           Ruby method name to callable syntax

    foo&.bar        Ruby check nil before calling bar

    foo?.bar        Swift optional presence check 


    if(x = foo!.bar!) {
         x.something()
    }


    foo ?? bar      Swift nil-coalescing

    foo || bar      Ruby nil-coalescing    

    <<1,4,8,45>>    Erlang bit syntax (binary literals), with typing and endianess

    5b432140        Erlang arbitrary base literals

    List comprehensions Erlang, Python, 

    Binary comprehensions in Erlang
    2> Pixels = <<213,45,132,64,76,32,76,0,0,234,32,15>>.
    <<213,45,132,64,76,32,76,0,0,234,32,15>>
    3> RGB = [ {R,G,B} || <<R:8,G:8,B:8>> <= Pixels ].
    [{213,45,132},{64,76,32},{76,0,0},{234,32,15}]
    -- from LearnYouSomeErlang

    Show anon fn’s in many languages using utf8 λ.

    Swift property lifecycle callbacks