Created
September 13, 2010 19:29
-
-
Save fitzgen/577861 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //@use bind.jsm | |
| function returnsMultipleVals () { | |
| return ["foo", "bar"]; | |
| } | |
| var foo, bar; | |
| bind foo, bar = (returnsMultipleVals()); | |
| console.log(foo); | |
| console.log(bar); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro bind var:a ',' var:b '=' expr:val gensyms:temp { | |
| (function (temp) { | |
| #a = temp[0]; | |
| #b = temp[1]; | |
| return temp; | |
| }(#val)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //@use each.jsm | |
| each (num in ([1,2,3,4])) { | |
| console.log(num); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro each '(' var:item 'in' expr:arr ')' block:body gensyms:garr,gi,glen { | |
| var garr = #arr; | |
| var gi = 0; | |
| var glen = garr.length; | |
| for ( ; gi < glen; gi++) { | |
| #item = garr[gi]; | |
| #body | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Expansion of tests/testdata/bind.js | |
| //@use bind.jsm | |
| function returnsMultipleVals () { | |
| return ["foo", "bar"]; | |
| } | |
| var foo, bar; | |
| (function (___gs_temp_0) { | |
| foo = ___gs_temp_0[0]; | |
| bar = ___gs_temp_0[1]; | |
| return ___gs_temp_0; | |
| }((returnsMultipleVals()))) ; | |
| console.log(foo); | |
| console.log(bar); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Expansion of tests/testdata/each.js | |
| //@use each.jsm | |
| var ___gs_garr_0 = ([1,2,3,4]); | |
| var ___gs_gi_1 = 0; | |
| var ___gs_glen_2 = ___gs_garr_0.length; | |
| for ( ; ___gs_gi_1 < ___gs_glen_2; ___gs_gi_1++) { | |
| num = ___gs_garr_0[___gs_gi_1]; | |
| { | |
| console.log(num); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment