Adding some Lua documentation

118 views
Skip to first unread message

Cefan Daniel Rubin

unread,
Mar 13, 2021, 4:07:39 PM3/13/21
to cosmopolitan cosmonauts
Dear all

I'm a very happy new cosmonaut. I've been converting a generic static-site text processor I wrote in Lua ages ago to benefit from living in the land of APE and it really works well! I wanted to get the following to work:
  1. Being able to extend the lua base with platform-specific functions (like luafilesystem)
  2. Pass along command-line arguments to an initial Lua file
  3. Enable Lua sripts to require other Lua files from within the zip archive
And I would like to share the simple steps with others.

Could something like this be helpful in the Documentation section of the site:


If so please shout if you suggest changes. Happy to mold it if needed. Thanks again justine and crew! :)

 - Cefan

Justine Tunney

unread,
Mar 14, 2021, 12:49:12 AM3/14/21
to Cefan Daniel Rubin, cosmopolitan cosmonauts
package.path = 'zip:?.lua' is a brilliant insight. I had no idea it would be that simple.

Looking at the luafilesystem package I'd recommend caution. Those things likely weren't included in Lua for a reason. Cosmopolitan makes i/o primitives easier but that doesn't make them any less hairy. For example, there currently isn't a windows polyfill of readlink and posix advisory locks. Cosmopolitan should polyfill those things, but reading links isn't something I'd want to encourage people to do, since I'm not convinced it has a use case and it probably needs root on windows. Having readdir() would be good but please note it currently isn't polyfilled to support the zip file system.

--
You received this message because you are subscribed to the Google Groups "cosmopolitan cosmonauts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cosmopolitan-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cosmopolitan-libc/f290a1c9-710e-4c98-8de1-4b584089d5fcn%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

cd rubin

unread,
Mar 14, 2021, 8:56:52 AM3/14/21
to Justine Tunney, cosmopolitan cosmonauts
Fanks for the feedback. I've removed the link related functions from
the morelua.c example - the directory iterator is really the function
I think is more important. I've also added a note to the apelua.md
file not to expect directory iterators over the zip filesystem to work
quite yet. Cheers!
Reply all
Reply to author
Forward
0 new messages