Spacing in NativeFunction underspecified
mgol opened this issue · comments
If I understand correctly, the specified syntax for NativeFunction
:
function IdentifierNameopt ( FormalParameters ) { [ native code ] }
doesn't specify how spaces are laid out. I expect spaces in the above line are needed for readability of the output so the real spaces in the output should be determined by a special symbol like <SP>
, shouldn't they?
For comparison, this is the output of Array.toString()
in Chrome 55:
"function Array() { [native code] }"
In particular, there is no space after IdentifierNameopt or before & after native code
.
@mgol If you can show that there is already a reasonable compatibility for spacing between existing implementations and that a resolution of any incompatibilities will not be web-breaking, I would happily accept a PR to specify the spacing for the cases which are currently only required to be matched by NativeFunction
.
From my tests, the stringification:
`function Array() { [native code] }`
is used by Chrome, Edge & the old Android Browser (4.1-4.3) while the one:
`function Array() {
[native code]
}`
is used by Firefox, Safari & Android 2.3.
IE 11 uses:
`
function Array() {
[native code]
}
`
(with an additional new line at the beginning and the end) but that shouldn't matter since Edge switched to match Chrome.
There are three options here:
- One of the two groups decides to switch to the other group's format (who can be pinged to provide us with their decisions?).
- The syntax is specified to allow one of the two formats but nothing else.
- We leave it as it is now.
I'd prefer (1), then (2), if (1) turns out not possible. What do you think?
EDIT: The 4th option would be to specify sth like:
function <SP> IdentifierNameopt <SP>opt ( FormalParameters ) <SP> { StrWhiteSpace [ native <SP> code ] StrWhiteSpace }
which is matched by all browsers (Edge included) except IE.
Also, do you have examples of native functions that either don't specify IdentifiedName
or provide a non-empty FormalParameters
list?
I agree with using function
.<SP>
IdentifierNameopt <SP>
opt ( FormalParameters ) <SP>
{ StrWhiteSpace
[ native <SP>
code ] StrWhiteSpace
}