From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: RFC: String interpolation Date: Thu, 8 Dec 2016 13:37:43 -0500 Message-ID: <0e6143f6-456b-5086-db27-439df4a5be27@gmail.com> References: <51825111-ace4-f750-4077-026a3b648d27@gmail.com> <87r35iwkg7.fsf@fastmail.fm> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sCW34DE7CPBNtUbIn31xUiX0FHi8xEh2H" X-Trace: blaine.gmane.org 1481222333 25549 195.159.176.226 (8 Dec 2016 18:38:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 8 Dec 2016 18:38:53 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 Cc: Emacs developers To: Joost Kremers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 08 19:38:47 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cF3ag-00056e-EV for ged-emacs-devel@m.gmane.org; Thu, 08 Dec 2016 19:38:46 +0100 Original-Received: from localhost ([::1]:48233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cF3ah-0005Zo-2t for ged-emacs-devel@m.gmane.org; Thu, 08 Dec 2016 13:38:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cF3Zu-0005OA-Rx for emacs-devel@gnu.org; Thu, 08 Dec 2016 13:38:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cF3Zp-00056l-Sq for emacs-devel@gnu.org; Thu, 08 Dec 2016 13:37:58 -0500 Original-Received: from mout.kundenserver.de ([212.227.17.10]:55445) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cF3Zp-00055s-HR for emacs-devel@gnu.org; Thu, 08 Dec 2016 13:37:53 -0500 Original-Received: from [18.26.2.123] ([18.26.2.123]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.184]) with ESMTPSA (Nemesis) id 0M6xID-1cbpmb3UA9-00wmrJ; Thu, 08 Dec 2016 19:37:49 +0100 In-Reply-To: <87r35iwkg7.fsf@fastmail.fm> X-Provags-ID: V03:K0:CrmIuI+PiraOKASlJX5dsgwIlk3k7JSM9dh4g1U0ooJdhjlKPnO xvNGSkQkr+L66cAPzGUiU3MK1ipD4TvBSpnw5MwLBxpJ3soejAN84goYKrP//oYPIblZ5eN cHZz0SJadfQUDLf8RzlOqZZhkOaP5Lo6449QEE7gPsefcsT3LPnr/oVUmjDhMuUNVdtsxPI pC5v+JINPzS7jKRnSM3OA== X-UI-Out-Filterresults: notjunk:1;V01:K0:yk3mpqzMbUY=:Wgzh+jyUzzKtvsfG5faFob 2mo70SnMhgoRPiJWOE3CU1bwRsjKS4yc7HpHfd2mgVzCrxxRx7P335Kvk5CuHBbPudSpLtLKV NYBx0P1b56YOvi5VCbmkcm7B+TSHrPhW8Td7DTA/EDFfTLd8VS79mWmYaag792GJEt1A+iut/ PFZ4W5h56bTPatBU1xRs3epTBsQ0Po1iNVOHZ7STR7RaEDPgVGV1FYmnXX3G8gP9ZmQ7b/0oD x/ARZSedDppBPTo/mYe/H3Qq271eihDph1aGAOh12jRwtiMnMsQU6pgHXXIAE0Nj4aUPmZjDr NJIHySmz3NM8QXIoHdtmO9ozXp5m5MyHC5dWI5+A+e1uvOHH8qCdTnKJzzxjzOUBSmtBrjxKO 9+h71c1MC9gvDihTLH3MZXGFHyUTCdYFnshVI/9tZDojEtXOpUPUKAn4prPqmrcCj5MiPAOGI uN7aX7Yw0MNZd0b/0k10w9pgHP3DZuOIDA8bJYvQUkBrPwBu9ooVidzH/8mRgibjpZtnC8GWU ouQgNxbByMmu7EpfIHziYDwvR2LP0cbB0h2+c7MPve81fjhYeS2qd8qCfKVE4o2MByrJ+7wVZ mOOtTULknTJX5iyKGau6Bg+VUfAeXS0u1ZhBnSedxVi7Zagl6VCozJUfV0tsSVWPOmTum2ZUz gO0Dc7kTinfLBOP07fGdt37pJ7AecvHezeWZOrI0/1upoMNKkogoSuyoLcqXRCissz9k= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.10 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210145 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --sCW34DE7CPBNtUbIn31xUiX0FHi8xEh2H Content-Type: multipart/mixed; boundary="5KUsPFbbDj7QeWkil9RMVfuuwIOQ8hdq3"; protected-headers="v1" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: Joost Kremers Cc: Emacs developers Message-ID: <0e6143f6-456b-5086-db27-439df4a5be27@gmail.com> Subject: Re: RFC: String interpolation References: <51825111-ace4-f750-4077-026a3b648d27@gmail.com> <87r35iwkg7.fsf@fastmail.fm> In-Reply-To: <87r35iwkg7.fsf@fastmail.fm> --5KUsPFbbDj7QeWkil9RMVfuuwIOQ8hdq3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2016-12-08 09:43, Joost Kremers wrote: >> (let ((password "letmein")) (fmt "The password is ${password}")) =E2=87= =92 >> "The password is letmein" >=20 > Why the {}? Is there any context in which $ is ambiguous such > that ${} is needed to resolve it? Other than vectors, I mean Yes, unfortunately: you can include virtually anything in a Lisp variable= name. (let* ((a 1) (b 2.0) (a/b (/ a b))) (fmt "$a/$b =3D ${a/b}")) > I honestly must say I find these last two very confusing. I would > simply write: >=20 > (fmt "Today is $(format-time-string \"%Y-%m-%d\" current-time)).") >=20 > The escaped double quotes are not perfect, but I find this much more > readable and more pleasant to look at. I really dislike the escaped quotes, but it might just be me :) This was inspired from Python's per-type format string, but I'm open to b= etter syntax suggestions :) > Perhaps you should also look at abo-abo's hydra package, since he > does basically the same thing in his hydra doc strings. AFAICT, it > works this way: % starts a placeholder, ` marks the start of the > expression. If the expression is an s-expr, you can leave out the `. Thanks for the reference! Do you know how it knows where to stop after a= backtick? > So, summarized: >=20 > - % : format the value of where can be a symbol > or an s-expr, possibly also a vector or a string (somewhat > superfluously...) > > - %` : format according to . >=20 > Of course, It might be easier to use a different symbol for %, I > don't know. I have nothing against using $. Thanks, that's a nice syntax too. I used $ based on a quick review of ht= tps://en.wikipedia.org/wiki/String_interpolation . I'm a bit worried abou= t the lack of delimiter after `, though; maybe it would help to see what = the example above (with $a/$b and $a/b) would look like in that syntax. >> fmt expands the strings at compile time (so they must be constant >> strings). >=20 > I've occasionally appreciated the fact that I can pass a dynamically > created format string to `format'... ;-) Ok, I could always use > `format' in such cases. Yes; otherwise, fmt becomes a thinly veiled eval, and that isn't great. Cheers and thanks for the feedback! Cl=C3=A9ment. --5KUsPFbbDj7QeWkil9RMVfuuwIOQ8hdq3-- --sCW34DE7CPBNtUbIn31xUiX0FHi8xEh2H Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYSah3AAoJEPqg+cTm90wjL0cP/1kv9C0rBr7CYsq/NNj9OQXy bh5YeCzE0SolNnOZLEvpMXKw4+mFX3Ih3TBw0FOJvZ2jv5NokuDO4vs4rXQBF1/J qCWXZC2RPasirnT55eDo+FgXjr2mr8EvzwmFTCDd+bq4mANysK1r30tzXRRR7Orw Mo5aXK4zvKdTL8792qngkEhUSQVx/1zMkvNtPvoreJuwuq6ZiQOhF9vo85UV3ee0 d5h8D46DWj+4fEQZ3lpKwquo0r1ex0xUa6tlhpRBfd7qQozUUpue69gUPA2W7adc A+wKWqqPx9SYKgvkBClh5bTpYyJS0YzMznAkEvQqGQcIIdO7X9VGYXdd7zSVXYXj 41XXSWsYmUEV3o1MwAlhjaD9K9O7ce/CO7u7omjIk0q1iMKXsO4iiueaO4+J6bGZ rPXfTHsZHE2orrD/bv0iJA27tMmtYWgVWTDdr7a9yRHVukLRILn39llXSRu2UajO eRQr7QbS9Z7zNJc74Bg6H9Dq7nT/LG6vAJGv5iQuAo9eYX5RcKxS9i4EI41EgC/G OvjOL2Roiy92jHraQmehsg1tnpZC+FZD0rklJWUlAnBYgbMR7TQKJIiS08eem6fM B0nG4KEgmOsUR4gVrcBzFYS397S6egtnfz9zVwwuIdIB2z78jc2Biy7+zE9Yd62k 6KEaxNUUKq1jinIRUYb2 =YVxE -----END PGP SIGNATURE----- --sCW34DE7CPBNtUbIn31xUiX0FHi8xEh2H--