If your language has if/then/else, and you're not a coward, then you're forced to invent some amount of dependent types
Conversation
Wait are you suggesting that x should be in scope after the block ends?
1
2
Oh right; I would rather (in the context of C) think of it as returning an rvalue, rather than x itself (i.e. with the name “x”) continuing to be in scope. This is how Rust does it
1
1
eg
let foo = if b { let x = 42; /* … */ } else { let x = “foo”; /* … */ };
x is not in scope after the block, but foo is, and the two branches must return unifiable types in the commented portion
1
1
I think julesh is wanting something like:
let x : if b { i32 } else { &str };
if b { x = 69 } else { x = "Nice" }


