4 ms·
That is a pretty awful MATLAB perk, using 'i' as the sqrt(-1) (and indexing the arrays from 1...). It makes polyglot programmers make a lot of silly mistakes.
by pfortuny 14y ago
That is a pretty awful MATLAB perk, using 'i' as the sqrt(-1) (and indexing the arrays from 1...).
It makes polyglot programmers make a lot of silly mistakes. It would have been SO easy to call the imaginary constant just 'I' instead of 'i'...
- TeMPOraL 14y agoOr just make it not mutable. Throw a big, fat error when someone assigns value to i.
- chimeracoder 14y agoOr better yet, do what Python does. Require a constant in front of the 'i', even if it's only '1'. Since identifiers can't begin with a numeral, there's no way to shadow a valid use of a complex number this way.
- pfortuny 14y agoThis would have been the best way to learn it, some kind of 'CRASH Eh! MAN your files have been formatted and all this project has been deleted because i=sqrt(-1) Sorry for the mess, hope you learn from this...' But I keep tripping over the same stone...
- KMag 14y agoPresumably the parent meant to throw an exception and show a script-level stack trace, not silently exit with no diagnostic messages. Insisting on doing something, even if it's the wrong thing, is much worse in most applications than refusing to run in order to avoid producing incorrect and misleading results.
- jpwright 14y agoThat would drive mathematicians insane, and this is coming from an electrical engineer's standpoint (where we use j instead)