Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!217.188.199.168.MISMATCH!takemy.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1987234.4suMY2Rx6P@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Wed, 12 Mar 2014 04:08:49 +0100 User-Agent: KNode/4.11.5 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <868d8999-f1b7-49bb-a33c-4e76b00ecafa@googlegroups.com> <531f2b05$0$6660$9b4e6d93@newsspool2.arcor-online.net> <60636642.clnVRmuXiz@PointedEars.de> <531f52ab$0$6670$9b4e6d93@newsspool2.arcor-online.net> <1406720.0V7e0g0dhT@PointedEars.de> <531fa3de$0$6656$9b4e6d93@newsspool2.arcor-online.net> MIME-Version: 1.0 Lines: 111 NNTP-Posting-Date: 12 Mar 2014 04:08:51 CET NNTP-Posting-Host: 50edfeda.newsspool1.arcor-online.net X-Trace: DXC=CRSA[cPRGYfPXlQ;h]GTMdic==]BZ:afn4Fo<]lROoRankgeX?EC@@`0E8X5N4L0EbDZm8W4\YJNlYUVHKH;GI^g<_e=dZX Thomas 'PointedEars' Lahn wrote: >> Christoph Michael Becker wrote: >>> Thomas 'PointedEars' Lahn wrote: >>>> Christoph Michael Becker wrote: >>>>> I suggest to use ECMAScript Arrays the way they're meant to be used, >>>>> and use indexes from 0 to n, and scale them as appropriate. >>>> >>>> As long as the “length” property is not used directly, it can be useful >>>> to have an *Array* instance with user-defined properties whose names >>>> are string representations of negative numbers, positive numbers >>>> greater than 2³² − 1, and non-integers. >>> >>> While you're surely right that having "non negative" properties *can* be >>> useful sometimes, it might often be confusing (particularly for >>> beginners). >> >> Non sequitur. I expect people to use their brain while programming, IOW >> not to treat those special arrays as if they were ordinary arrays. >> >>> Not only the length property will not work as "expected", >> >> Depends on the implementation. You are forgetting getters. > > -v, please. ,----[JSX/array.js:278] | | /** | * @memberOf __jsx.array.BigArray | * @private | */ | var _length = 0; | | /** | * Sets the real length of this array | * | * @param {int} value | * @throws jsx.array.RangeError | * if the value is less than 0 or | * greater than {@link BigArray.MAX_LENGTH} | */ | this.setLength = function BigArray_setLength (value) { | if (value < 0 || value > _BigArray.MAX_LENGTH) | { | return _jsx.throwThis(_RangeError, | ["Invalid length", value, | "0.." + _BigArray.MAX_LENGTH | + " (2^" + Math.floor(Math.log(_BigArray.MAX_LENGTH) | / Math.log(2)) + ")"], | BigArray_setLength); | } | | _length = Math.floor(value); | | return this; | }; | | /** | * Returns the real length of this array | * | * @return {int} | */ | this.getLength = function () { | return _length; | }; | | /** | * @memberOf jsx.array.BigArray | * @name length | */ | _defineProperty(this, "length", { | "get": this.getLength, | "set": this.setLength | }, "jsx.array.BigArray"); | `---- _defineProperty() is just an import of jsx.object.defineProperty() in JSX:object.js which in turn is a wrapper for Object.defineProperty() [ES5.x, 15.2.3.6] or the proprietary ways of defining setters and getters if the former is unavailable. >> But now I am thinking of a property defining whether you can have >> negative indexes on the object, modifying that behavior slightly. >> FWIW, the “length” property could then yield the difference between the >> maximum positive and the minimum negative index or just the maximum >> positive index + 1 as it always had; > > How about having new properties or methods, say lbound and ubound. > These would be useful for iterating over the elements with for loops. Yes, much better. >> how did you get the idea that “for” loops would stop working >> for >> those objects *per se*? > > I have not got this idea. I've written: > > | Element access via the bracket notation as well as for loops will > | work on such "arrays". Sorry, I misread. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not Cc: me. / Bitte keine Kopien per E-Mail.