Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27691
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Why does it slow down for bases above 10? |
| Date | 2015-05-16 17:58 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <3842368.OIKdPzKKP9@PointedEars.de> (permalink) |
| References | (3 earlier) <2805604.EO7ul1Ts0Q@PointedEars.de> <f302e2cc-e93c-4901-9f74-3451814bbf45@googlegroups.com> <877fs91ndu.fsf@bsb.me.uk> <b7795ebe-6732-41dc-8cc7-32ef9e9eb779@googlegroups.com> <878ucoon0v.fsf@bsb.me.uk> |
Ben Bacarisse wrote: > jonas.thornvall@gmail.com writes: >> The functions and algorithms are developed as the need for them occur >> that does not mean i do not want general working code, quite the >> opposite there is a need for it since many functions work upon the >> same operand arrays. > > This is why you must avoid globals. They will mess up the key > separation you need to have bignums with bignum bases. If do nothing > else, do this. Remove every global variable that you can so that > all your functions compute results only from their arguments. He does not even have global variables. He has deletable properties of the ECMAScript global object at best, assuming that each of the assignments is successful as the scope chain is considered. If an object in the scope chain has a property with the same name and that cannot be written to, the result of the assignment can be throwing an exception or causing an unrecoverable runtime error. (This is different from e.g. Python, where symbols are local unless assigned to in the global execution context or declared global in a function context.) For the amateur programmer and the more experienced programmer not accustomed to using an ECMAScript implementation, the easiest way to see where they went wrong is to test their code in a modern browser that uses an implementation of ES 5+, and enable strict mode by prepending a line containing onlya "use strict"; to their code. In this case, the first assignment to an undeclared symbol will throw a ReferenceError exception. One can then determine if the symbol actually needs to be globally available. If not, one should declare it a local variable by using the “var” statement in function context; otherwise, “var” in global context to declare it a global variable. One should then endeavour to eliminate as many global variables as possible through refactoring. Finally, the script console and code linters such as JSHint can show further common mistakes, however the warnings generated by those tools should be considered carefully as some of them are bogus or the result of a too strict configuration. This approach can be more efficient than a rewrite. -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-15 11:57 -0700
Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-15 12:25 -0700
Re: Why does it slow down for bases above 10? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-15 21:41 +0100
Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-15 14:20 -0700
Re: Why does it slow down for bases above 10? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-15 23:21 +0200
Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-15 14:37 -0700
Re: Why does it slow down for bases above 10? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-15 23:34 +0100
Re: Why does it slow down for bases above 10? "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-16 01:27 +0200
Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-16 01:53 -0700
Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-16 02:18 -0700
Re: Why does it slow down for bases above 10? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-16 11:05 +0100
Re: Why does it slow down for bases above 10? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-16 17:58 +0200
csiph-web