[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] ArrayBuffer, Concatenation and String-Array Conversion, a proposal
- To: firstname.lastname@example.org
- Subject: [Public WebGL] ArrayBuffer, Concatenation and String-Array Conversion, a proposal
- From: Samuel Kleiner <email@example.com>
- Date: Tue, 5 Oct 2010 21:17:27 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:content-type :content-transfer-encoding:subject:date:message-id:to:mime-version :x-mailer; bh=CLyYUycmUabviyvecCBXn2A8QYl9WfsMdu6GVJ5NA/k=; b=cDzVvfsXaOMuNm9Hnxq0L/L3yk48ZYyRCbj3xUFBOnbLKrf9HWdLJcPQ9nmAitERWw FuYIzdwbVS2Xdyu+34OAMLoO+1H+j4dB5npb2T8bFhWk2E+V3iPQeQSM1V+JYQYB5/LR HomfmVR05q733AlLAmwVooqDoGZ4j2AJNFwEo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; b=wDEFAx6XEQsE26wsc80Rw+QPdQzyva7cygX5mU6HckALYd1VJkQQLkDTHJXG74lKNZ sHDT1wLRhzAhjcLTLyul5nXF1SNQfazIh8UUesY5NMqLyZJ8vCdbnoob8F8miTpisUXj 5c+Dhr8Xjx6fJEiY1r9uG/7VRLVDgNXyn7rdc=
- Sender: firstname.lastname@example.org
Here are a few proposals for the typed arrays specification, that I think would help with the intuitiveness of that proposal. First of all, array concatenation.
In the current spec, when concatenated via the + operator, arrays stringify.
(new Int32Array()+new Int32Array()).length == 38
In my proposed spec change, arrays would concatenate into the same type, if both sides were the same, otherwise an arraybuffer would be returned.
(new Int32Array()+new Int32Array()).length == 2
(new Int32Array()+new Int8Array()).length == 5
The use case for this would be building primitive structs, and also progressive downloads of arraybuffer data.
Converting strings to arrays:
In the current spec, no conversion is made:
RangeError: ArrayBufferView size is not a small enough positive integer.
In my proposed spec change, the constructor for the individual arraybuffer specialized types take string arguments, and instantiate an arraybuffer with the individual unicode code points bitmasked to the size of the data type, here 0xFF) This would be easy to understand and provide reasonable compression of data.
new Int8Array("data") == 100
One use case would be converting compressed vertex data embedded in json. This would also be a use case for immutable array buffers, if such are specified.
Converting arrays to strings:
Use case: I can't really come up with one, but it seems useful.
You are currently subscribed to email@example.com.
To unsubscribe, send an email to firstname.lastname@example.org with
the following command in the body of your email: