[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: io.format (was: Reported to the Bloat Police: string.pack, .unpack and .packsize!)
- From: "John Hind" <john.hind@...>
- Date: Sun, 23 Aug 2015 11:50:33 +0100
>Date: Sat, 22 Aug 2015 17:08:14 -0400
>From: Sean Conner <sean@conman.org>
>I'll give "complex" a pass (given the the modifiers you can add), but
>where do you get "arbitrary" from?
> %d - decimal output of a number
> %o - octal output of a number
> %x - hexidecimal output of a number
> %s - string
> %f - float
> %q - quoted string
I'll give you a reciprocal pass on "arbitrary" then (though why 'x' for
hexadecimal
rather than 'h'?). My point is: why does this syntax not aspire to the same
degree
of readability as the rest of Lua? I do not think a proposal to shorten ALL
of Lua's
keywords to one letter prefixed by a randomly selected punctuation symbol
(what have percentages got to do with string formatting?) would be
considered
sensible! (OK, I've just taken back my pass on "arbitrary"!)
>Also, a format string does make it easier to handle translations.
>Granted, this is geared more for compiled languages like C where (depending
>on the platform) it might be impossible to load variations on code (like a
>shared library [1]) but it can also be applied to languages like Perl, Lua,
>Ruby or Python.
I get why C did this (especially in conjunction with the "resource" system
in Windows
EXE files, which supported positional tokens long before Python)), but it is
not necessary
in a scripting language. It is just as easy (and much more flexible) to
write a translation
support tool that emits Lua source for functions in a table as strings in a
table.
> -spc (Why the hate for format strings? Did printf() bite you as a kid?)
It still bites me every day! It (plus regular expressing patterns, string
literal escapes and
now pack/unpack codes) are the only things I have to dig out a reference
manual for
every time I use them. It does not help that the Lua reference manual can't
be
bothered to document format strings completely, referring out to "the ISO C
function
sprintf", so now I need a C reference to hand as well as a Lua one!
-John
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus