On Wed, Nov 25, 2009 at 8:17 AM, Wes Garland <
w...@page.ca> wrote:
> ByteString, ByteArray
>
> - If we're supporting base-32, why not base-64 and quoted-printable? I've
> actually had to use the latter pair in real-world code with ByteStrings
We've got them. Look closely at toString(radix). The only reason
that base32 has its own alphabet is because there are two standard
alphabets for base32.
> - Why are we ditching "new"?
> 1. creating ByteStrings without the new operator this way conflicts with
> GPSEE's FFI-oriented cast syntax, where ByteString(thing) makes a
> ByteString out of thing (assuming thing is of a reasonable type for that).
It's in the rationale. I'll fix ByteArray, but ByteString matches
String minus support for boxed types, which I presume you'll be
thankful not to have to implement since they wouldn't be useful in the
short term.
> 2. I like "new", all the other classes are using it for instanciation.
The intent is that ByteArray and ByteString need to be
future-compatible with native equivalents.
> - I like where you're going w.r.t. enumerability on instance props. Can we
> go whole hog and explicitly say "only bytes are enumerable"? Then we can
> safely write code like
>
> for (i in a)
> print(a[i][0]);
I'm worried that specifying that kind of thing in great deal, and
other things that need to be true for an ECMA specification like
typeof ByteString() == "bytestring", will make it impossible to write
fully compliant prototypes in the short term. This might not be a big
deal. I'll see what I can do.
> - What's with Get and Put? Why are methods starting with capital letters?
> Do you mean reading and writing to []?
They're italic to distinguish internal properties. I'll see what I
can do to make that more clear too.
> - What exactly is Content? A reference to the constructor? What is the
> rationale for this? Are we trying to graft a type system onto CommonJS?
This is an idea from Daniel Friesen's proposal. He would probably be
better at explaining the use case, and whether this specification
fulfills his requirement.
> - returning ByteString[x] for toSource is wrong. toSource() should
> generate legal source code. Thus, something like
> require("moduleID").ByteString([x]) is more appropos (although I think it
> should include 'new')
Okay.
> Bit Types
>
> - Bit-endianess is almost certainly both superflous and an anti-feature.
> AFAIK there is not a single processor on the market today which does not use
> little-endian bit order. Even portable, low-level C code (like drivers and
> stuff) will assume little bit endian arch.
I think it might have been an error to make endianness an issue for
Byte-Bit conversion. I'm going to review this.
> - You have not touched at all on word endianness, which IS important. This
> also means you need to work on word-size, and potentially think about
> mixed/middle endian syntax (ARM, PDP-11, ???) .
Endianness is covered implicitly for the IANA stuff. If someone could
write up an explanation of how to construct different endianness
charset identifiers, I would like to include that in the
specification. If you could explain what mixed endianness is, maybe I
can fit it in somewhere. I do not thing, apart from that, endianness
comes into play with anything written so far, since there are no
word-level conversions yet. It's my intention to augment the Number
type to create byte and bit strings of various endiannesses.
> - I do not see a justification for bits vs. bytes in the current proposal,
> unless you want to implicitly say "please use a smaller backing store" to
> the implementor. The fact that you made several thinkos copy-pasting from
> Byte to Bit types reinforces this to me. What are Bit types to be used for?
> C gets by without a bit type, and it certainly does plenty of low-level
> work.
I'm hoping Brian Mitchell can chime in with some requirements for bit
data types. They come from the Erland side of the world and come
highly recommended. I, having no experience with such things, can
only assume that the purpose is to make things like non-byte quantized
encodings, like base32, easier to implement using slice. I'm sure
you've noticed that non-power-of-2 radix are hard to implement.
> - If we are really serious about supporting Bit types, bitwise operations
> must be supported. Shift, Roll, and, not, or, xor at a minimum I think.
I'm not sure. It might be adequate to do these operations with forEach and map.
> Standard Class Monkey Patching
>
> - I am still strongly opposed to implicit modifications of the standard
> classes happening when a CommonJS module is loaded! If we want to patch
> standard classes, I believe explicit patching from the calling/using
> programmer should be used:
>
> const binaryD = require("binaryD")
> binaryD.patch(String, Array);
It's my intent that these would not be instantiated when the module is
loaded, just carried by the exports of the module. In this case the
module is just being used as a name space, not for the mechanics. The
specification does not indicate that these changes to base classes
should occur as a result of loading the module. Really, these ought
to be primordials and a rigorous implementation would implement them
fully in the engine, with the same diligence as the existing
primordials.
> General Requirements
>
> "None of the specified prototypes or augmentations to existing prototypes
> are enumerable."
>
> I believe that statement makes it impossible to implement the String and
> Array monkey-patches in a pure ES3 environment. Although, [] might be ...
> tricky or impossible as well.
It specifies that properties of the prototype are not enumerable.
That does not preclude enumerable instance properties.
> Rationale
>
> - The paragraph about Pack and Unpack is confusing to me. Are those Java
> methods or something? Do we need to specify what this is not?
This is in the errata. I do not think it's important to define these
things yet. Pack, unpack, and calcsize are a byte-quantized unpacking
API supported by Perl, Ruby, PHP, and Python, at the very least.
> - Encoding methods -- on the one hand, we say "we're not doing codecs", on
> the other hand, we have base-32, custom alphabets, blah blah.
It says we aren't doing encoding-named methods, which distinguishes
this proposal from the first proposal. I'll try to make that more
clear.
> - Future proofing, instanceof -- I'm convinced that making instanceof work
> where possible is a good idea, although I'm not sure that working across the
> sandbox boundary is required. It definitely complicates the implementation,
> because it means that the only way to protect the prototype is to freeze it.
Yeah, agreed. I should clarify that the scope of this proposal is
intended to be implementable today with a certain degree of ease (so
we can build momentum and make claims like "I made a compliant
implementation") and also be ready for a future when there are more
rigorous implementations. I think that if you want to make an
implementation that pre-sages a native specification, that would be
fine, but I don't want to make it a requirement for compliance this
year. Eventually, these should be true, to be in keeping with
precedent:
typeof ByteString() == "byteString"
typeof new ByteString() == "object"
ByteString() instanceof ByteString == false
new ByteString() instanceof ByteString == true
typeof ByteArray() == "object"
typeof new ByteArray() == "object"
ByteArray() instanceof ByteArray == true
new ByteArray() instanceof ByteArray == true
Object.prototype.toString.call(ByteString()) == "[object ByteString]"
Object.prototype.toString.call(ByteArray()) == "[object ByteArray]"
> - Memory Optimization -- agree whole heartedly. Many GPSEE operations are
> aware of "under the hood" memory allocation details of immutable
> ByteString-like types. We will share underlying storage between related
> types (like a ByteString and a slice of it) and maintain weak references as
> appropriate, blah blah. No COW yet, but it's also on the list.
Awesome. I hope this is satisfactory to Maciej from Apple.
> Agreement on decodeToString. Frankly, I just assign toString to
> decodeToString in the prototype in my current code anyhow..
Oh, good. I expected this to be contentious.
Kris Kowal