|
Re: string conversion, format functions: msg#00342lang.erlang.general
On Wed, 23 Apr 2003 23:39:28 +0200 Matthias Lang <matthias@xxxxxxxxxxxx> wrote: > 9> B = 3. > 3 > 10> io:fwrite("~4.4.0w\n", [B]). > 0003 > ok > > integers are formatted using the 'term' format (~w), there's no need > for an explicit 'integer' format. Wow. Would you believe, I got so used to using ~p that I completely forgot ~w even existed? When I started using it, I just assumed ~p behaved exactly like ~w, only prettier. I didn't think to check that the format parameters had a different meaning. Now I'm starting to see some of the lovelier warts of io:format :) If ~n is defined to be \n on all platforms then it's completely redundant. It just gives you a false sense of abstraction. ~r doesn't exist. If format parameters mean different things for different formatting codes then programs written with io:format become that much harder to read and maintain, becuase they require that much more memorization. (I can never remember which leading integer is field width and which is precision anyway.) And then there's ~i. That's just disturbing. It's almost funny. Thankfully, I couldn't find it used anywhere in OTP with a quick grep. (If it is, it's used with a field width or precision... and that's even more disturbing.) If hex/other bases are added to io:format, it'll just get nastier. Not really a problem at this point though, since whatever elegance there once was in it has apparently already left town :) It's kind of strange, when you think about it, have there even been any significant advances in "output formatting technology" since, what, FORTRAN? None that have caught peoples' imagination enough to be adopted, anyway - Perl's 'reports' are pretty nice, but I don't think I've ever seen a Perl program that actually *uses* them... -Chris |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: trouble with files bigger than 4GB: 00342, Vance Shipley |
|---|---|
| Next by Date: | Re: string conversion, format functions: 00342, Jay Nelson |
| Previous by Thread: | Re: string conversion, format functionsi: 00342, Matthias Lang |
| Next by Thread: | Re: string conversion, format functions: 00342, Shawn Pearce |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |