4 ms·
Incredibly cool hack. But i'm going to be the first one to point out that having function arguments not evaluated at call time is very, very unintuitive. Anyon
by mappu 12y ago
Incredibly cool hack.
But i'm going to be the first one to point out that having function arguments not evaluated at call time is very, very unintuitive. Anyone with a background in traditional (procedural/OO) languages is reasonably going to expect both `perform_side_effects` calls to be invoked here.
var ctest = cond_1(a == 1, 2 + perform_side_effects1(),
a == 2, 3 + perform_side_effects2(),
0)
- adrusi 12y agoThis is why the rust people require a bang in macro names. The behavior is just too confusing if what looks like a normal function is actually evaluating its arguments in a non-strict manner. Scala is another language that supports declaration-site opt-in for non-strict evaluation, very similarly to how swift seems to be doing it. I'm not the biggest fan of Scala, but my limited experience with it has left me with the impression that you can't trust any normal-looking code to actually be normal until you look at its documentation and/or source.
- MaulingMonkey 12y agoTo play devil's advocate, they already have to worry about: - exceptions short circuiting one of the side effects (C++, C#, etc.) - the indeterminate order of execution of the side effects (C, C++) - macros with conditional evaluation behavior (such as assert depending on... _DEBUG? NDEBUG?)