I don't think I understand what ArrayType means in version 3 - its not a type ?
var PA = ArrayType.buildPar([40,20], (i,j) => ..., StructType({ x: uint8, y:uint8}));
vs
var PA =buildPar([40,20], (i,j) => ..., StructType({ x: uint8, y:uint8}));
-----Original Message-----
From: dev-tech-js-engine-rivertrail-bounces+nrubin=
nvidi...@lists.mozilla.org [mailto:
dev-tech-js-engine-rivertrail-bounces+nrubin=
nvidi...@lists.mozilla.org] On Behalf Of Herhut, Stephan A
Sent: Wednesday, June 26, 2013 1:00 AM
To:
dev-tech-js-en...@lists.mozilla.org
Subject: buildPar proposals
* PGP - S/MIME Signed by an unverified key: 06/25/2013 at 10:00:20 PM
Dear all.
As promised, here is my take on the three current proposals for a buildPar primitive with their pros and cons. As for type specifications, I am not sure where one needs to use new and where it can be omitted. So feel free to throw in a new whenever you think one is missing.
Version 1: Adding build/buildPar to instances of ArrayType (frame driven)
var T = new ArrayType( ArrayType( StructType({ x: uint8, y: uint8}), 20), 40); var PA = T.buildPar(2, (i,j) => ...);
In this variant, the programmer first specifies the type for the overall result, including the result's shape. That type is then consecutively used to construct the corresponding data object using buildPar. The first argument gives the depth, i.e., the number of top-level ArrayType constructors to consider as frame (iteration space).
For my taste, the iteration space is too well hidden in this example. Also, it is cumbersome to type these ArrayType nesting but that can probably be solved by a nice library.
Version 2: Adding build/buildPar to instances of all types (grain driven)
var T = StructType({ x: uint8, y: uint8}); var PA = T.buildPar([40,20], (i,j) => ...);
Here, the programmer only specifies the type of the grain and gives the iteration space directly as first argument to buildPar. I find this easier to read, as the iteration space is provided directly. However, it is somewhat odd that buildPar is a method on a non-array type.
Version 3: Adding build/buildPar to ArrayType itself
var PA = ArrayType.buildPar([40,20], (i,j) => ..., StructType({ x: uint8, y:
uint8}));
This version is modelled closely to how map works. buildPar is a method of ArrayType and directly constructs a data-object (which might seem odd). The advantage here is that all the information that matters is on one line.
Another advantage is that this form can easily be extended to support multiple results. I wrote an earlier message on this[1]. In essence, one can add multiple type descriptors to the call to new like so
var PA = ArrayType.buildPar([40,20], (i,j) => ..., StructType({ x: uint8, y:
uint8}), float64);
Here, PA would be an Array of two results, each an 40x20 array, one containing structures, the other float values.
Stephan
[1]
https://groups.google.com/forum/#!topic/mozilla.dev.tech.js-engine.rivertrail/ai0qFK4brxc
* Herhut, Stephan A <
stephan....@intel.com>
* Issuer: Intel Corporation - Unverified
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------