Open exists-forall opened 11 years ago
Why?
Because expensive_row_calculation!
and expensive_column_calculation!
would only have to be calculated once, not twice. Also, is the multidimensional_array
is sparse, the hashing of expensive_row_calculation!
would only have to be performed once to get the column array.
Also, there's a convention within macro-like systems (of which moonscript is one) that expressions should be evaluated only as many times as they are written. For example, python's neat
a < b < c
syntax (which is basically a macro, albeit a language level one, in that it is a syntactic shortcut) is not exactly equivalent to
a < b and b < c
because b
is only evaluated once in the first case.
Again, this is very minor. It's a small detail, and it doesn't really matter if it's addressed. I just thought it would be worthwhile to bring it up because there are situations where it makes a noticeable difference which form it the update compiles to.
Ah, I posted my question before you edited your post :) Yeah, for multidimensional it's handy. But for single- it can theoretically bring some overhead (copying numbers?), so better use it only for multidimensional
Yeah this is definitely a bug. I'd like to fix this.
compiles to
although it should be
My intuition tells me that, in addition to other "principle of least surprise advantages", this would improve efficiency for situations such as