Closed
Bug 556488
Opened 15 years ago
Closed 15 years ago
Reduce the context-sensitivity of the grammar
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: cdleary, Unassigned)
Details
Attachments
(1 file)
9.27 KB,
patch
|
Details | Diff | Splinter Review |
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 ( http://developer.yahoo.com/yui/theater/video.php?v=eich-yuiconf2009-harmony ), 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:
assertTrue(isNAN(⍨⍨/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,
Leary
Comment 1•15 years ago
|
||
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; };|?
/be
Comment 2•15 years ago
|
||
(Don't forget the decompiler!)
/be
Comment 3•15 years ago
|
||
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•15 years ago
|
||
I have prepared a powerpoint slide for my presentation:
• ⍨
• ☃
• ✔
Reporter | ||
Comment 5•15 years ago
|
||
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•15 years ago
|
||
> What could
> be simpler than |var var = function (function) { return function * function;
> };|?
(define list (lambda lambda lambda))
Comment 7•15 years ago
|
||
cdleary: I believe your comment 5 is a dup of http://quotes.burntelectrons.org/3574
Comment 8•15 years ago
|
||
Dammit, Jim beat me to it.
Comment 9•15 years ago
|
||
Fnord.
Reporter | ||
Updated•15 years ago
|
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•