Saving a table in file

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Saving a table in file

Miles Bader-2
Philippe Lhoste <[hidden email]> writes:
> Oh, well, that's better than the toto, titi, tata variables French
> programmers use often when they lack imagination, not unlike foo, bar,
> baz...

ugh, there's nothing quite as fun as trying to understand a hairy piece
of code where there are no comments and the most important variables
have names like like "foo"... :(

-Miles

--
Bacchus, n. A convenient deity invented by the ancients as an excuse for
getting drunk.
Reply | Threaded
Open this post in threaded view
|

Re: Saving a table in file

steve donovan
In reply to this post by spir ☣
On Tue, Mar 9, 2010 at 8:45 PM, spir <[hidden email]> wrote:
> FWIW: I found this convention fully self-understanding in your code samples.

It's true that Hungarian has gone out of fashion and never was part of
the dynamic scene, but naming function _arguments_ in a clear
conventional way does make life easier for the user who has to
understand that function.

function fun(sName,nAge,lChildren)

where s means 'string', n means 'number', l means 'list' (in the sense
of an array-like table). And so forth.

>From that, you can pretty much generate good initial LuaDocs stubs ;)

Using explicitly named types wherever possible is also helpful:

http://lua-users.org/lists/lua-l/2009-08/msg00142.html

And then, if our named 'struct' was Fred, then aFred makes perfect sense.

steve d.
Reply | Threaded
Open this post in threaded view
|

Re: Saving a table in file

Enrico Colombini
steve donovan wrote:
> It's true that Hungarian has gone out of fashion and never was part of
> the dynamic scene, but naming function _arguments_ in a clear
> conventional way does make life easier for the user who has to
> understand that function.

...except when you change the type of an argument and have to edit
variable names everywhere, or when the same argument can have different
types :-)

   Enrico
Reply | Threaded
Open this post in threaded view
|

Re: Saving a table in file

steve donovan
On Thu, Mar 11, 2010 at 10:21 AM, Enrico Colombini <[hidden email]> wrote:
> ...except when you change the type of an argument and have to edit variable
> names everywhere,

Well, that breaks the API so a little effort is needed. Our tools
should be clever enough to do this kind of thing these days.

> or when the same argument can have different types :-)

There you have me!  So often an innocent argument to a Lua function
can be either a number, or a string, or perhaps a table (with rather
flexible structure!)  I find documenting such functions to be awkward
using tools like LuaDoc - maybe from the point of view of the doc tool
(and the browser of the API) these are best _presented_ as overloads?

steve d.
12