Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Why io::format() type is not an iolist?

Received: by 10.204.128.207 with SMTP id l15mr2401405bks.4.1345057454269;
        Wed, 15 Aug 2012 12:04:14 -0700 (PDT)
X-BeenThere: erlang-programming@googlegroups.com
Received: by 10.204.13.17 with SMTP id z17ls1541707bkz.5.gmail; Wed, 15 Aug
 2012 12:04:13 -0700 (PDT)
Received: by 10.204.129.81 with SMTP id n17mr2406397bks.3.1345057453894;
        Wed, 15 Aug 2012 12:04:13 -0700 (PDT)
Received: by 10.204.129.81 with SMTP id n17mr2406396bks.3.1345057453882;
        Wed, 15 Aug 2012 12:04:13 -0700 (PDT)
Return-Path: <erlang-questions-boun...@erlang.org>
Received: from hades.cslab.ericsson.net (hades.cslab.ericsson.net. [192.121.151.104])
        by gmr-mx.google.com with ESMTP id e23si530132bks.0.2012.08.15.12.04.13;
        Wed, 15 Aug 2012 12:04:13 -0700 (PDT)
Received-SPF: pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) client-ip=192.121.151.104;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of erlang-questions-boun...@erlang.org designates 192.121.151.104 as permitted sender) smtp.mail=erlang-questions-boun...@erlang.org; dkim=neutral (body hash did not verify) header...@gmail.com
Received: from hades.cslab.ericsson.net (hades [192.121.151.104])
	by hades.cslab.ericsson.net (Postfix) with ESMTP id AAF035C098;
	Wed, 15 Aug 2012 21:04:04 +0200 (CEST)
X-Original-To: erlang-questi...@erlang.org
Delivered-To: erlang-questi...@erlang.org
Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com
 [209.85.212.169])
 by hades.cslab.ericsson.net (Postfix) with ESMTP id 450305C006
 for <erlang-questi...@erlang.org>; Wed, 15 Aug 2012 21:04:03 +0200 (CEST)
Received: by wibhm2 with SMTP id hm2so5099686wib.4
 for <erlang-questi...@erlang.org>; Wed, 15 Aug 2012 12:04:02 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=message-id:date:from:user-agent:mime-version:to:subject:references
 :in-reply-to:content-type:content-transfer-encoding;
 bh=f9z7X3JWW+x664vBtznJ8fy+4Bk5BRBnxpvhE3LYnpU=;
 b=VhwfWqmY1VX8+3a8hRFBo3rI4V6nUydWgy597oAi9RcBIs3EIDam09Joo1HLT8j1VI
 +a/GQsrBkB15XkviOiLcxKeldJLSv7yZ52V6CPM9n0DCLQFM0Ypp0xdQvs1EFTvtrNZD
 cgICvOJ3mD35h14IgU7fESEMFsruNO5MACQgcZZbdCZ4Fx2par994z3Nqs31T45Vlane
 SSLhJaRcn8x+mw02mfoX6IZviXq7XZK2s1dWImZfRNPcQs98dmH6JntsVSDcpZFSchcb
 UjFGytAPPufjMfXSfNnse403qd/cXNB8wJNpa1Ys99rTtMNs2I2grWke6tHI2wa7ItNi
 DM2w==
Received: by 10.216.238.79 with SMTP id z57mr11406749weq.184.1345057442750;
 Wed, 15 Aug 2012 12:04:02 -0700 (PDT)
Received: from [192.168.43.59] (213-204-52-149.amt.ax. [213.204.52.149])
 by mx.google.com with ESMTPS id q4sm30336494wix.9.2012.08.15.12.03.58
 (version=TLSv1/SSLv3 cipher=OTHER);
 Wed, 15 Aug 2012 12:04:02 -0700 (PDT)
Message-ID: <502BF29D.7050...@gmail.com>
Date: Wed, 15 Aug 2012 22:03:57 +0300
From: Richard Carlsson <carlsson.rich...@gmail.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:14.0) Gecko/20120714 Thunderbird/14.0
MIME-Version: 1.0
To: erlang-questi...@erlang.org
References: <CANLxesKb7gy1WTnqpch+LkJ7RZjJ0H82v9UTO4Rt=SuHCS2...@mail.gmail.com>
In-Reply-To: <CANLxesKb7gy1WTnqpch+LkJ7RZjJ0H82v9UTO4Rt=SuHCS2...@mail.gmail.com>
Subject: Re: [erlang-questions] Why io::format() type is not an iolist?
X-BeenThere: erlang-questi...@erlang.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: General Erlang/OTP discussions <erlang-questions.erlang.org>
List-Unsubscribe: <http://erlang.org/mailman/options/erlang-questions>,
 <mailto:erlang-questions-requ...@erlang.org?subject=unsubscribe>
List-Archive: <http://erlang.org/pipermail/erlang-questions>
List-Post: <mailto:erlang-questi...@erlang.org>
List-Help: <mailto:erlang-questions-requ...@erlang.org?subject=help>
List-Subscribe: <http://erlang.org/mailman/listinfo/erlang-questions>,
 <mailto:erlang-questions-requ...@erlang.org?subject=subscribe>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: erlang-questions-boun...@erlang.org
Sender: erlang-questions-boun...@erlang.org

On 08/09/2012 10:45 AM, Aleksandr Vinokurov wrote:
>
>
> Hello all
>
> I've found the subject and did not understand the root of such
> restriction: why io:format/2 can't understand iolist for a Format arg?

In order to interpret the Format argument, it would need to flatten the 
iolist first anyway. For example, io:format(["~",[<<"w">>]], [Term]). 
It's simply easier from the library's point of view to just say that the 
Format argument needs to be a flat string (guaranteeing that there's no 
needless overhead for flattening in the majority of cases), and if you 
have an iolist, then define your own format function like this:

   format(IOList, Args) ->
     io:format(binary_to_list(erlang:iolist_to_binary(IOList)), Args).


   /Richard

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions