Path: csiph.com!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Multi-line string literals (was: What I learned today) Date: Thu, 05 Jan 2017 23:29:16 +0100 Organization: PointedEars Software (PES) Lines: 169 Message-ID: <1890337.irdbgypaU6@PointedEars.de> References: <61vn6c9nh0dsl9k89ab5s17vbvqa5a8l5k@4ax.com> <48dq6ctt3kf3p49slepna386aq8dgl81n3@4ax.com> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1483655358 2211 eJwFwYEBwCAIA7CXpkDBc6Da/09YEoYFpiPgoZA87lEcleE5LzCXPTD5xjbYZzcg63z+babYck4FiSw+U3Zo3bKafda3PSG+5tKbQv+76x9c (5 Jan 2017 22:29:18 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Thu, 5 Jan 2017 22:29:18 +0000 (UTC) User-Agent: KNode/4.14.2 Cancel-Lock: sha1:/4Tcz7ewbOjYj2+aIGMVjjMwTIc= X-User-ID: eJwFwQkBwDAIBDBL/OXkwAD/Epa4Bsf3LDzMzw8KwHrU0iOiBsmz5tU8c0t3rk9ALruU+kpItg3ga6DyB0K1FSU= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. On 5/01/2017 12:13 PM, Scott Sauyet wrote: >> I believe the following argument should clear things up immensely: >> >> [Swahili for “It is impossible to separate form and content”] >> >> HTH, > > On the contrary. It should be: > > [“… mau$hui”] Serendipitously, your little OT exchange had a tangible benefit: It led me to find out that, starting with ECMAScript 2016, there is, *finally*, a more convenient, Python-like way to write multi-line string literals than to suffix each line with “\n\”: template literals. Note that the characters produced by the /LineTerminatorSequence/ production are allowed to occur *unescaped* in such a literal. Therefore, the ECMAScript 2016 program (which can be executed conveniently in, e.g., the Chrome DevTools console already) var argScott = `01010011 01000111 01000110 01110000 01100100 00110010 01010110 00110110 01011010 01010111 01110100 01101000 01100010 01101101 01101011 01100111 01011010 01101101 00111001 01110100 01100100 01010011 01000010 00110000 01100010 00110010 01011010 01101000 01100100 01011000 01010010 01110000 01001001 01000111 00110101 01101000 01001001 01000111 00110001 01101000 01100100 01010111 01010010 01101111 01100100 01010111 01101011 00111101`; var argAndrew = `01010011 01000111 01000110 01110000 01100100 00110010 01010110 00110110 01011010 01010111 01110100 01101000 01100010 01101101 01101011 01100111 01011010 01101101 00111001 01110100 01100100 01010011 01000010 00110000 01100010 00110010 01011010 01101000 01100100 01011000 01010010 01110000 01001001 01000111 00110101 01101000 01001001 01000111 00110001 01101000 01100100 01010011 01010010 01101111 01100100 01010111 01101011 00111101`; console.log(window.atob(argScott.split("\n").map( (i) => String.fromCharCode(parseInt(i, 2)) ).join(""))); console.log(window.atob(argAndrew.split("\n").map( (i) => String.fromCharCode(parseInt(i, 2)) ).join(""))); is syntactically valid and functionally equivalent to the Python program I would have written instead: #!/usr/bin/env python3 from base64 import b64decode argScott = """01010011 01000111 …""" argAndrew = """01010011 01000111 …""" print(b64decode("".join( [chr(int(i, 2)) for i in argScott.split("\n")] ))) print(b64decode("".join( [chr(int(i, 2)) for i in argAndrew.split("\n")] ))) #--------------------------------------------------------------------------- However, that aside, Andrew, I do not follow your “argument”. Is there a “$” character in Swahili? Because that appears to be the only difference between your “argument” and Scott’s. BTW: You are welcome, and Happy New Year. -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.