lua-users home
lua-l archive

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


On 21/01/2020 06.38, Sean Conner wrote:
Okay, let's see if the community can just come together to define the
minimum viable module for directory functions. […]

	cat = list([name])

		Obtain a list of files in the given directory; if not given,
		use the current working directory.  Return an array of
		names, or nil on error (error reporting TBD).

		NOTE: 	The ordering of entries is unspecified.
			None of modules I've listed have this specific
			functionality.

	fun,state,var = glist([name])

		Returns an interator (function, state, var) for use in a for
		statement.  Each time the function is called, a new filename
		is returned.

		NOTE:	The ordering of entries is unspecified.
			All three modules have this function, although
			it's called files() under luaposix.

What should happen with '.' and '..'?

Should they be excluded?  This would potentially (extremely rarely)
cause confusion on file systems which lack one and/or(?) the other when
someone blindly assumes that they exist.

Or should they be included, leading to fun for/if layers everywhere
(>99.999…%) (or custom ad-hoc wrapper functions) because you don't want
them when doing… practically everything?  (I guess that's also a fun
learning experience for beginners of all proficiencies everywhere, when
they're first trying to do a recursive traversal…)

-- nobody