|
|
|
|
|
by 6gvONxR4sf7o
251 days ago
|
|
There's more to this that I'd absolutely love to see in a language, and I can't tell if rye supports. If you want an ergonomic `if` you need its scope aspects too. Consider this example <beginning of the function>
x = ...
if foo:
y = ...
else:
x = ...
y = ...
<rest of the function>
Critical parts of the ergonomics are thata) in each branch, we have everything in scope that comes from <beginning of the function> b) in <rest of the function>, we have everything in scope that was assigned or reassigned in the executed branch I'd love a language that supports programmable stuff like if, since I'm tired of python autodiff not handling `if` and `for`. But it would really need programmable scope stuff to still allow the ergonomic "scope effects" that make `if` and `for` blocks ergonomic. |
|
Rye has first class contexts and it's one of more exciting things to me about it, but I'm not sure it's related to what you describe above. More on it here:
https://ryelang.org/meet_rye/specifics/context/
One thing that pops out at the example above is that I wouldn't want to define a y inside if block, because after the if you have y defined or not defined at all, at least to my understanding of your code.
Rye is constant by default, most things don't change and you need less veriables because it's expression based and it has left to right "flow" option. So you only make variables where you really need them, which is less common and specific, it should be obvious why you need a variable.