Binary data: Structs and ArrayBuffers

Jussi Kalliokoski jussi.kalliokoski at gmail.com
Mon Dec 3 11:53:28 PST 2012


I was just reading through the binary data proposal [1] and I have a few
comments / questions:

First of all, how will this integrate with the Typed Arrays? Will a struct
have an intrinsic ArrayBuffer? What about an ArrayType instance? If they
do, how will it react to typeless properties? Are typeless properties
allowed in the first place (IIRC there was a talk I watched where David
Herman or someone else said that this might be)? Will you be able to
extract structs out of an ArrayBuffer?

What about strings? Looking through the binary data related proposals,
there seems to be no good way of extracting strings from binary data.
Should we have, for example StringType(DOMString encoding, uint length,
boolean isPadded=false) for Structs? Or, should DataView have a method for
extracting a string from it? What about storing one?

Pointers. Now it's useful if a struct can contain an array of arbitrary
size, but we don't have pointers. We can't let the struct be of arbitrary
size either. What are the thoughts on this?

Arrays inside structs. Are there plans for this? They're not absolutely
necessary, but often quite handy anyway, for example:

StructType({
  unique: uint32[4]
})

Is way simpler to manage than:

StructType({
  unique0: uint32,
  unique1: uint32,
  unique2: uint32,
  unique3: uint32
})

Also, what's the plan with Typed Arrays anyway? Are we going to adopt them
as a part of JS or leave it as an extension?

Binary stuff is hard in a language like JavaScript, but I think that
ultimately we'll get something workable, and would love to see more
discussion around this!

Cheers,
Jussi

[1] http://wiki.ecmascript.org/doku.php?id=harmony:binary_data
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121203/6efcc66a/attachment-0001.html>


More information about the es-discuss mailing list