From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!.POSTED!not-for-mail
From: Lars Ingebrigtsen <larsi@gnus.org>
Newsgroups: gmane.emacs.devel
Subject: Re: RFC: String interpolation
Date: Mon, 12 Dec 2016 19:33:25 +0100
Message-ID: <m3mvg19eve.fsf@gnus.org>
References: <51825111-ace4-f750-4077-026a3b648d27@gmail.com>
	<8737hwnc52.fsf@lifelogs.com> <m34m2bj2m2.fsf@gnus.org>
	<8c117f5c-209a-97d8-79ce-a78f707f0545@gmail.com>
	<m3wpf7hjzf.fsf@gnus.org>
	<76c9c475-0180-aa49-3d4a-006d4e3f943c@gmail.com>
	<m3oa0ifgvd.fsf@gnus.org> <m2k2b6rxaj.fsf@gmail.com>
	<m38trmdun6.fsf@gnus.org>
	<jwvr35dub31.fsf-monnier+gmane.emacs.devel@gnu.org>
	<m3r35dcwht.fsf@gnus.org>
	<89a6a20d-e135-caad-6b31-760ab7ac90fc@cs.ucla.edu>
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: blaine.gmane.org 1481568403 5379 195.159.176.226 (12 Dec 2016 18:46:43 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 12 Dec 2016 18:46:43 +0000 (UTC)
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
To: Paul Eggert <eggert@cs.ucla.edu>
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 12 19:46:38 2016
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>
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 <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>)
	id 1cGVcS-0000G0-VC
	for ged-emacs-devel@m.gmane.org; Mon, 12 Dec 2016 19:46:37 +0100
Original-Received: from localhost ([::1]:33027 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>)
	id 1cGVcX-00086J-8F
	for ged-emacs-devel@m.gmane.org; Mon, 12 Dec 2016 13:46:41 -0500
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45145)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <larsi@gnus.org>) id 1cGVPt-0005Rr-UQ
	for emacs-devel@gnu.org; Mon, 12 Dec 2016 13:33:39 -0500
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <larsi@gnus.org>) id 1cGVPp-0008Po-6B
	for emacs-devel@gnu.org; Mon, 12 Dec 2016 13:33:38 -0500
Original-Received: from hermes.netfonds.no ([80.91.224.195]:50847)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <larsi@gnus.org>) id 1cGVPo-0008PF-W1
	for emacs-devel@gnu.org; Mon, 12 Dec 2016 13:33:33 -0500
Original-Received: from cm-84.215.1.64.getinternet.no ([84.215.1.64] helo=stories)
	by hermes.netfonds.no with esmtpsa
	(TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2)
	(envelope-from <larsi@gnus.org>)
	id 1cGVPh-0000nq-8w; Mon, 12 Dec 2016 19:33:27 +0100
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEWxKhXtbSjmVh38qU/8
	tVXzhjf9xVf4mkXk+LsdAAACVUlEQVQ4jVWTUXLdIAxFHa8geIbpb8wWoGYBEPob5w1lAWbob16w
	q+33CuPXhD/r+EpXQgxE2hJRTaHgWK2NWUrxftAV4IjphnDIlCoZow0AVY34Gn+XkomiPGQ6jrgA
	6CMiHqHf9teYEtRU/5aBrJUyEiFTfqWY4pEi0gHQIQTRwqWLq7vW1eMjA9yfkm7xjCIVtrzxgRWf
	Y1qaU9IxMTAenwyebiWUP/AQJeruzvpL8WOz5SfHZSVdjQPIJyibjUJIkVAE5V3Ip0IaigBCxKPW
	irF4gMSAaBWTmrkf0uyLi9v7iD+FUBMAuqYOkv0chVjVPCk1CwAomisGSgnVDqpICFxLRfehxV4a
	WBMS6cDgYIBEDFAlaWdybsU/AcQJlJDJMUCNaj+GUfWD6gSFZ8CKUc0XkYnbu1INAF02C5j1Jpyu
	QF6GcWB3czIlu3B2PlwHInnDBNt9HPTxiA9N4F0Hb/8F87oHv7l+gw+ANqIp2uvKID2AmpTYfThN
	fUmFsczRZJOdMdxH7KANBKV1dropeqretskhbxQCliHGtyuOQfGGOBQKHuD5imO0RjuNRTQhNEWf
	0hpv+gTeI9X6PHbBijXHjYds+OGs4iuw2gJA4QfRQdu3xNuOB4h9+AawcC2VR67vighbKJz9kjuY
	cTiedrQd4Gt7KGYWIBU7Qh9cY2rxDiryY01CvsA043mwYmGvJ7jWFhK45UQeCzHwu+BFn9gu1Yoh
	YnszALK/X30QVto47XxmV0q+Y+HENOEJJtptxRzLNiCFxLNhC+i8zQRLWn79A7BrEPawpUdWAAAA
	AElFTkSuQmCC
In-Reply-To: <89a6a20d-e135-caad-6b31-760ab7ac90fc@cs.ucla.edu> (Paul Eggert's
	message of "Mon, 12 Dec 2016 09:46:05 -0800")
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
	[fuzzy]
X-Received-From: 80.91.224.195
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-devel/>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=subscribe>
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Original-Sender: "Emacs-devel" <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>
Xref: news.gmane.org gmane.emacs.devel:210367
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/210367>

Paul Eggert <eggert@cs.ucla.edu> writes:

> Why not just extend "format" so that it allows trailing "...%" in the
> format string to mean "argument value spliced here"? After the
> argument you can continue on with the format, which must start with
> the rest of the conversion specification. E.g.:
>
>   (format "Altitude= %" alt ".2f, direction = %" dir ".2f.")
>
> might output "Altitude = 300.57, direction = 240.93."
>
> That way, you can easily replace the expressions without giving them names:
>
>   (format "Altitude= %" (+ alt 100) ".2f, direction = %" (- dir) ".2f.")

Hm, that's a solution I don't think I've seen in any other languages?  I
think this looks kinda attractive...

The readability is somewhat hindered by all the quote marks, but if you
format it differently

(format "Altitude= %"
	(+ alt 100)
	".2f, direction = %"
	(- dir)
	".2f.")

it's perhaps clearer.  But the "%" on one line and the ".2f" on the next
is perhaps not optimal?  Hm...  What about something like...  er...

(format "Altitude= %.2f%" (+ alt 100) ", direction = %.2f%" (- dir) ".")

Does that look clearer?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no