Reduce the context-sensitivity of the grammar




9 years ago
9 years ago


(Reporter: cdleary, Unassigned)


Firefox Tracking Flags

(Not tracked)



(1 attachment)

Created attachment 436447 [details] [diff] [review]
code ☃ unicode

In order to provide the obvious direct benefit to the browser end-user. Tests are in the ecma_4_1 directory.

I was inspired by the use of unicode in the lambda suggestion Brendan made ( ), so I wrote this patch to replace infix '<' operator with '☃' and the regex delimiter character '/' with '⍨'. This lets you elegantly express common idioms like left shifting a number by an E4X object:

    assertTrue((1 ☃☃ <html><head><title>Useful!</title></head></html>) == 1);

And dividing a regexp by a named value i:


All of the existing tests that use either regexes or the infix less-than operator (including the use of imacro_asm.js at build time and the test runner itself) become legacy upon acceptance of this patch. If that's not acceptable for whatever reason, we can support the new characters as another one of our small set of language extensions.

If accepted as a backwards-incompatible change in the language proper, somebody should volunteer to write a small guide to porting the existing internet for webmasters and serve as a contact. Someone will also have to volunteer to update the disassembler to get rid of the legacy syntax output. Unfortunately, writing the patch disqualifies me -- I can't hog all the fun.

With ☃3,

I suggest also making all binary operators have optional unary prefix form, denoting the obvious identities: +x -> 0 + x, *x -> 1 * x, etc.

Also, in the humble spirit of PL/I and Immanuel Kant's "Prolegomena to Any Future Metaphysics", I suggest unreserving all reserved identifiers in all contexts. This will increase simplicity, which is above all other virtues, and help reduce the size of future "JavaScript: the goodest parts" book. What could be simpler than |var var = function (function) { return function * function; };|?

(Don't forget the decompiler!)

Also based on Gregor's fine work at bug 502736 we should have new operators for dividing by 2 and 8, and anything else needed to tune for SunSpider no matter how much fun people make of us. SunSpider is the future! Indeed we should error-correct this "mistake":

math-partial-sums.js:    var a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0.0;

since it is clear the programmer meant for a2-a9 to be locals, and all of a1-a9 to be initialized to 0.0 if not 0.00, which might matter if IBM decimal comes to pass along with PL/I FTW! peaceout

Comment 4

9 years ago
I have prepared a powerpoint slide for my presentation:

 • ⍨
 • ☃
 • ✔
I think I see where you're going with this -- perhaps we can take a lesson from the truly great general purpose compilers in history and peephole optimize the benchmark as a whole. We can provide users with O(1) completion of otherwise computationally expensive algorithms-that-just-happen-to-be-in-benchmarks by embedding a big lookup table from a rolling bytecode checksum to a result!

Comment 6

9 years ago
> What could
> be simpler than |var var = function (function) { return function * function;
> };|?

(define list (lambda lambda lambda))

Comment 8

9 years ago
Dammit, Jim beat me to it.
Last Resolved: 9 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.