Re: UInt8ClampedArray Bitwise operators?

2015-08-12 Thread Isiah Meadows
I can see why, since nearly everyone depends on that coupling. Minifiers depend on it. Mixin utilities depend on it. Breaking the Web would be an understatement. On Wed, Aug 12, 2015, 14:36 Brendan Eich bren...@mozilla.org wrote: Caitlin Potter wrote: ES2015 already has element accessor

Re: UInt8ClampedArray Bitwise operators?

2015-08-12 Thread Isiah Meadows
Oh. Pardon my ignorance. Misunderstood the idea. On Wed, Aug 12, 2015, 23:19 Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Aug 12, 2015, at 7:30 PM, Isiah Meadows wrote: I can see why, since nearly everyone depends on that coupling. Minifiers depend on it. Mixin utilities depend on it.

Re: UInt8ClampedArray Bitwise operators?

2015-08-12 Thread Caitlin Potter
Oh, forgot to add a bit to those snippets to divide the bytes_per_element into bits, but yeah On Aug 11, 2015, at 2:55 PM, Michael McGlothlin mike.mcgloth...@gmail.com wrote: SIMD types appear almost as limited in size as using numbers. Often I need to manipulate thousands or millions of

Re: UInt8ClampedArray Bitwise operators?

2015-08-12 Thread Caitlin Potter
Well, you could just use typed arrays for this, and add a helper function which retrieves the bit at a specific index. Like, something like this: ``` function bitset_get(ta, i) { var e = (i / ta.BYTES_PER_ELEMENT) | 0; i = i % ta.BYTES_PER_ELEMENT; return (ta[e] i) 1; } ``` You could

Re: UInt8ClampedArray Bitwise operators?

2015-08-12 Thread Caitlin Potter
ES2015 already has element accessor overloading with proxies, right? It's everything else that's missing. Proxies enforce invariants, which is problematic for this use case because it’s A) expensive, and B) also restricts you from “lying” about the actual properties which exist on the

Re: UInt8ClampedArray Bitwise operators?

2015-08-12 Thread Daniel Ehrenberg
On Wed, Aug 12, 2015 at 4:50 AM, Caitlin Potter caitpotte...@gmail.com wrote: Operator overloading or value types might make it look a lot prettier some day (though iirc element assessor overloading was off limits), but you could get pretty far by baking it into a compile-to-js language.

Re: UInt8ClampedArray Bitwise operators?

2015-08-12 Thread Jordan Harband
Also `instanceof` overloading via `Symbol.hasInstance` On Wed, Aug 12, 2015 at 10:44 AM, Daniel Ehrenberg dehrenb...@chromium.org wrote: On Wed, Aug 12, 2015 at 4:50 AM, Caitlin Potter caitpotte...@gmail.com wrote: Operator overloading or value types might make it look a lot prettier some

Re: UInt8ClampedArray Bitwise operators?

2015-08-11 Thread Michael McGlothlin
SIMD types appear almost as limited in size as using numbers. Often I need to manipulate thousands or millions of bits efficiently so fumbling around with numbers is messy. I've looked at several implementations on npm but none seemed very mature or standard. I guess it's philosophical as

Re: UInt8ClampedArray Bitwise operators?

2015-08-11 Thread Daniel Ehrenberg
Bits and bytes are fundamental to JavaScript too, which is why the language has, for a long time, included operations like , , , , |, ^ and ~ on Numbers, exposing the ability to manipulate 32-bit integers. This is comparable to what C provides. Like C, JavaScript has a relatively minimal standard

Re: UInt8ClampedArray Bitwise operators?

2015-08-11 Thread Brendan Eich
Daniel Ehrenberg wrote: Uint8ClampedArray is more of a historical artifact than something you should actually aim to use. Uint8Array is probably what you'd want to get at as a basis for a user-level library. Thanks for posting this, Daniel. Just to be super-clear (and I was around when it was

Re: UInt8ClampedArray Bitwise operators?

2015-08-11 Thread Daniel Ehrenberg
I don't think my earlier mail went through, so I'm posing it below for the record: SIMD types have bitwise operators, but SIMD.js exposes just fixed-size vectors that are optimized to what hardware can optimize certain operations for. A future extension (the long SIMD API) may operate on

Re: UInt8ClampedArray Bitwise operators?

2015-08-10 Thread Isiah Meadows
Do SIMD types solve your problem? https://github.com/tc39/ecmascript_simd On Mon, Aug 10, 2015, 10:58 Michael McGlothlin mike.mcgloth...@gmail.com wrote: Would there be a downside to extending Bitwise operators to work with typed arrays such as UInt8ClampedArray? To me it seems natural to