swift does it wrong

1 view
Skip to first unread message

Raoul Duke

unread,
Jan 18, 2022, 8:38:53 PM1/18/22
to pi...@googlegroups.com
if let
and 
guard else

quickly become just as terrible in real use when there's any complexity to the state or any non-throwing style error handling and logging. 

solving the small use cases was a nice try and is great when it works but quickly falls apart usability wise. 



David Barbour

unread,
Jan 19, 2022, 11:41:32 AM1/19/22
to pi...@googlegroups.com
My Glas language uses conditionals based on backtracking, i.e. `try/then/else`. If the `try` clause succeeds, we proceed to `then`, otherwise we backtrack (undoing effects of 'try') then proceed to `else`. In this design, it is not a problem for the `try` clause to adjust the environment (i.e. stack type, var types, etc.) locally for the `then` clause, i.e. similar to `if let` of swift. But without undoing effects, this pattern easily becomes very troublesome IMO because the system state received by the 'else' clause would be very unclear.

Raoul Duke

unread,
Jan 19, 2022, 11:47:20 AM1/19/22
to pi...@googlegroups.com
another thing i end up doing is wrapping some chunks of n existing bit of code that has conditionals into an iife lambda, especially when trying to emulate something like a clojure transient mutable block. 
Reply all
Reply to author
Forward
0 new messages