[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: module & 5.2
- From: Petite Abeille <petite.abeille@...>
- Date: Sun, 1 Apr 2012 23:10:37 +0200
On Apr 1, 2012, at 10:26 PM, Egil Hjelmeland wrote:
> Microlight [1]
> [1]https://github.com/stevedonovan/Microlight
Microlight? Micro? And light? Perfect.
Should be a piece of cake to use and package, no?
Let see…
$ lua test-ml.lua
* ml ml ./ml.lua -- additional print to indicates which module gets loaded
* mlx mlx ./mlx.lua -- additional print to indicates which module gets loaded
{10,20,{1,2},one=1,two=2}
the answer is 42
{100,400,900,3,2}
animal tiger
animal felix cat
true true
Good, good… hopefully Microlight doesn't leak any of its implementation… difficult to say as it's not self contained in its own _ENV… but lets hope…
Ok, lets try to package it with luac -o…
$ luac -o test-ml.luac ml.lua mlx.lua test-ml.lua
$ lua test-ml.luac
* ml
* ml ml ./ml.lua
* mlx
* mlx mlx ./mlx.lua
{10,20,{1,2},one=1,two=2}
the answer is 42
{100,400,900,3,2}
animal tiger
animal felix cat
true true
Seems to work… but… wait a minute… the modules are loaded twice… oh my, oh my… hopefully nothing broke… who knows… but lets hope…
Oh, well… what about packaging it as one file?
$ cat ml.lua mlx.lua test-ml.lua > test-all.lua
$ lua test-all.lualua: test-all.lua:696: <eof> expected near 'local'
Ooops… syntax error… hmmm… ok, lets wrap each file in its own block and concatenate all of that…
$ lua test-all.lua
* ml
Ooops… not going very far… these pesky return statements… oh, well… so much for packaging such lightweight library… after all, who would ever want to package a library in their own project… oh, wait...
(with apologies to steve :))