lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I mean, why not to let the string readable and printable? It's just
> a piece of string, readable strings are easy to debug, easy to
> process manually, and easy to talk about it for sure.
> 
> In other word, if there's a way to form them readable in one line,
> and could be used as source string as well, for purpose of ease, why
> not to do it?

There is a difference between "readable" and "in one line". Assume
the following string:

t = [[
GEN 1:1  In the beginning God created the heaven and the earth.
GEN 1:2 And the earth was without form, and void; and darkness was upon
the face of the deep. And the Spirit of God moved upon the face of the
waters.
GEN 1:3 And God said, Let there be light: and there was light.
GEN 1:4 And God saw the light, that it was good: and God divided the
light from the darkness.
GEN 1:5 And God called the light Day, and the darkness he called
Night. And the evening and the morning were the first day.
GEN 1:6 And God said, Let there be a firmament in the midst of the
waters, and let it divide the waters from the waters.
GEN 1:7 And God made the firmament, and divided the waters which were
under the firmament from the waters which were above the firmament: and
it was so.
GEN 1:8 And God called the firmament Heaven. And the evening and the
morning were the second day.
]]

What is more readable, (1) or (2) (see below)?

Of course, in this case, even better would be the original form, with
[[...]] (and multiple lines!). One size does not fit all needs, but it
is very easy to use 'gsub' to do the formatting the way it pleases you.


Output (1):
"GEN 1:1  In the beginning God created the heaven and the earth.\
GEN 1:2 And the earth was without form, and void; and darkness was upon\
the face of the deep. And the Spirit of God moved upon the face of the\
waters.\
GEN 1:3 And God said, Let there be light: and there was light.\
GEN 1:4 And God saw the light, that it was good: and God divided the\
light from the darkness.\
GEN 1:5 And God called the light Day, and the darkness he called\
Night. And the evening and the morning were the first day.\
GEN 1:6 And God said, Let there be a firmament in the midst of the\
waters, and let it divide the waters from the waters.\
GEN 1:7 And God made the firmament, and divided the waters which were\
under the firmament from the waters which were above the firmament: and\
it was so.\
GEN 1:8 And God called the firmament Heaven. And the evening and the\
morning were the second day.\
"

Output (2):
"GEN 1:1  In the beginning God created the heaven and the earth.\nGEN 1:2 And the earth was without form, and void; and darkness was upon\nthe face of the deep. And the Spirit of God moved upon the face of the\nwaters.\nGEN 1:3 And God said, Let there be light: and there was light.\nGEN 1:4 And God saw the light, that it was good: and God divided the\nlight from the darkness.\nGEN 1:5 And God called the light Day, and the darkness he called\nNight. And the evening and the morning were the first day.\nGEN 1:6 And God said, Let there be a firmament in the midst of the\nwaters, and let it divide the waters from the waters.\nGEN 1:7 And God made the firmament, and divided the waters which were\nunder the firmament from the waters which were above the firmament: and\nit was so.\nGEN 1:8 And God called the firmament Heaven. And the evening and the\nmorning were the second day.\n"

-- Roberto