A multi-core friendly switch symbol

A piece-wise defined mathematical operator or equivalent which is multi-core friendly

Version 1 (Original Version)

var i = 1 
let x = 0

switch(i){
    case 1:
    x=i
    break
    
    case 2:
    x=i+1
    break
    
    case 3:
    x=i-1
    break
    
    case 4:
    x=i^2
    break
}

Version 2

let x = { 
    i, when i==1;
    i+1, when i==2;
    i-1, when i==3;
    i^2, when i==4;
}

How is version 1 new syntax? What does version 2 do differently? And what does "multi-core friendly" mean?

Oh, sorry, I've updated the post to now indicate version 1 as the original version. A new symbol and/or construct which sends stronger optimization inferences to the compiler.

Thanks for the update. However, it is still unclear what kind of optimisation you are thinking of, and whether an optimisation hint would change any semantics. If it doesn't, I doubt there's much of an advantage over the current state of the art, compilers already optimise switch branching on primitive values with literal cases quite well.

1 Like