[ANN] Microlight 1.1

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

[ANN] Microlight 1.1

steve donovan
Hi all,

This is the first release candidate for the next iteration of
Microlight [1].  Since Github no longer believes in downloads, you can
grab the zip from here [2] and view the LDoc documentation online [3]

Microlight is a small-ish (800 lines odd, less than 600 actual code)
library of useful Lua utility functions.  It provides a simple
standard class mechanism and an Array class.

steve d.

[1] https://github.com/stevedonovan/Microlight
[2] http://stevedonovan.github.com/files/microlight-1.1.zip
[3] http://stevedonovan.github.com/microlight/

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

Michal Kottman
On 27 December 2012 18:55, steve donovan <[hidden email]> wrote:
Hi all,

This is the first release candidate for the next iteration of
Microlight [1].

Hi, thanks for the update!
 
Since Github no longer believes in downloads, you can
grab the zip from here [2]...

The downloads are not gone, they are just hidden/changed. While you cannot upload custom files, you can download the source code as a ZIP/tar.gz when you tag it using a version. The downloads are available here: https://github.com/stevedonovan/Microlight/tags

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

M. Edward (Ed) Borasky
In reply to this post by steve donovan
On Thu, Dec 27, 2012 at 9:55 AM, steve donovan
<[hidden email]> wrote:
> Hi all,
>
> This is the first release candidate for the next iteration of
> Microlight [1].  Since Github no longer believes in downloads,

Wait ... what?

--
Twitter: http://twitter.com/znmeb; Computational Journalism Publishers
Workbench: http://znmeb.github.com/Computational-Journalism-Publishers-Workbench/

How the Hell can the lion sleep with all those people singing "A weem
oh way!" at the top of their lungs?

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

steve donovan
On Fri, Dec 28, 2012 at 6:18 AM, M. Edward (Ed) Borasky <[hidden email]> wrote:
>> Microlight [1].  Since Github no longer believes in downloads,
>
> Wait ... what?

Yep, as Michal says, they don't allow you to upload custom files, but
it does look like you can still grab the source.  Not a biggie, since
they allow you to maintain your own pages as a repo.

.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

David Manura
In reply to this post by steve donovan
On Thu, Dec 27, 2012 at 12:55 PM, steve donovan
<[hidden email]> wrote:
> This is the first release candidate for the next iteration of
> Microlight [1].

A couple comments on only a quick look, assuming the meaning of the
functions should be clear from the documentation alone:

(1) ml.escape
  - How are "magic characters" and "escaping" defined?
string.match(s, '^'..ml.escape(s)..'$') == s for all s?

(2) ml.split
  - "split a string into a table of strings separated by a delimiter."
--> "split a delimited string into a table of strings."  (The table or
the strings in the table are not separated by a delimiter.)
  - "number of splits" unclear since splitting a string once yields
*two* parts (begin and end).
  - "table of strings" --> "array of strings"?  Compare to terminology
of "array" elsewhere.  Note: For better or worse, the 5.2 refman uses
"sequence."  Also, "a array" --> "an array" in many places.

(3) ml.expand
  - Is it obvious what $(1), $(true), and $(nil) should expand to?
(Note: In SLSLPP, the contents of $() is understood as an expression
not a name.)

(4) ml.readfile
  - no ml.writefile?  (See also lua-file-slurp.)
  - should docs mention that `nil,err` is returned on error?

(5) ml.tstring
  - "string representation" can be ambiguous in intended format.

(6) ml.collect_until(n, ...)
  - The word "until" suggests a variable number of iterations until a
predicate n is met, like "repeat ... until n".  Google
collect_until/collectUntil for examples.

(7) ml.imap
  - Note: This and other functions based on it operate in-place.

(8) ml.extend
  - Define "extend array" more formally?

(9) ml.indexby
  - Note: Equality in "indexby({one=1,two=2},{'one'}) == {1}" is
interpreted only informally.

(10) ml.ifind - Returns nil on not found?

(11) Mixing naming conventions?  equals_keys/equalskey v.s. issubset/is_subset?

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

steve donovan
On Fri, Dec 28, 2012 at 10:13 AM, David Manura <[hidden email]> wrote:
> A couple comments on only a quick look, assuming the meaning of the
> functions should be clear from the documentation alone:

That is fair, since we must go beyond 'Read the Source, Luke' as
advice on how to use libraries...

>   - "split a string into a table of strings separated by a delimiter."
> --> "split a delimited string into a table of strings."

That reads better. Sequence is the official term, although array is
clear enough (except when we speak of Array with a capital of
course!).   Number of splits works as expected, so that 2 gives us two
parts and so on, but this ought to be explicit.

>   - Is it obvious what $(1), $(true), and $(nil) should expand to?

This is gsub, so (a) $(1) is fine (b) $(true) is an error and (c)
$(nil) cannot happen. I'll make this more explicit, and use tostring()
to avoid errors at the cost of some correctness.

>   - no ml.writefile?  (See also lua-file-slurp.)

Logical enough!

> (6) ml.collect_until(n, ...)
>   - The word "until" suggests a variable number of iterations until a
> predicate n is met, like "repeat ... until n"

Sneakily named, because n is overloaded; it _can_ be a predicate which
ends the sequence.  Really should be collect_n and collect_until.

> (7) ml.imap
>   - Note: This and other functions based on it operate in-place.

It doesn't, but I agree that the docs should be clearer about that.
The in-place version is transform - not sure if that's a canonical
name for this operation (which naturally doesn't feature in the
functional lexicon)

> (11) Mixing naming conventions?  equals_keys/equalskey v.s. issubset/is_subset?

Ouch. Yes, that kind of thing irritates me as well. I like underscores
personally, any preferences?

steve d.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

Vadi
I like Lua's style, no underscores.
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

steve donovan
On Fri, Dec 28, 2012 at 11:01 AM, Vadim Peretokin <[hidden email]> wrote:
> I like Lua's style, no underscores.

Cool, so I'll consistently use that.

Note: this set of functions is not the 'final cut', since the
philosophy here is a compact set of well-defined functions that can be
composed to do many useful things.  I'm tending to optimizing-for-code
size at the moment as well.

So any function which is truly esoteric and of marginal use must go.

That's why there's 'spill-over' modules:
 - ml_properties  - classic property support (getter/setter or just setter)
 - ml_range  - Dirk's Vector class
 - ml_module - Lua 5.2 module construction that allow for flexible
explicit import (or just _G) without the visibility downside of
package.seeall.

steve d.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

Philippe Lhoste
In reply to this post by Michal Kottman
On 27/12/2012 20:00, Michal Kottman wrote:
> The downloads are not gone, they are just hidden/changed. While you cannot upload custom
> files, you can download the source code as a ZIP/tar.gz when you tag it using a version.
> The downloads are available here: https://github.com/stevedonovan/Microlight/tags

The download are gone if you want to provide an already built solution. We can now only
retrieve the source code. While it is logical for a source code repository, it is
impractical for those wanting to provide open source utilities for the general public, not
willing to learn to compile a project just to get a password manager...

And, well, (to keep on topic), the success of the LuaBinaries project shows it is just
convenient to quickly grab a binary for your platform rather than getting the sources,
finding the right project description or settings, downloading a compiler, perhaps a
project builder (make, CMake, etc.), and so on.
I prefer to get an IUP binary rather than using their special (perhaps awesome!) build
process. Yes, that's a kind of laziness for us programmers. Although at one time, I tried
to get Buildr (a project builder made in Ruby) with JRuby on Windows and just failed to
get the dependencies right...

I guess that the trend to have projects on multiple public repositories (often Google Code
+ GitHub) will grow as long as other repositories offer such download option.

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

Philippe Lhoste
In reply to this post by M. Edward (Ed) Borasky
On 28/12/2012 05:18, M. Edward (Ed) Borasky wrote:
> On Thu, Dec 27, 2012 at 9:55 AM, steve donovan
> <[hidden email]> wrote:
>> Hi all,
>>
>> This is the first release candidate for the next iteration of
>> Microlight [1].  Since Github no longer believes in downloads,
>
> Wait ... what?

https://github.com/blog/1302-goodbye-uploads

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

Rapin Patrick
> https://github.com/blog/1302-goodbye-uploads

In the blog, they say that the download feature has been removed because it was a source of "confusion" with the source code ZIP/tar archiver.
This looks like a ridiculous excuse to me. Does anybody know the _real_ reason for that decision?
Potentially downloads were too costly in terms of storage at Amazon, or GitHub feared illegal content usage like with Mega Upload ?

--
-- Patrick Rapin
-- coauthor of "Le guide de Lua et ses applications", D-BookeR
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

steve donovan
On Fri, Dec 28, 2012 at 7:08 PM, Rapin Patrick <[hidden email]> wrote:
> Potentially downloads were too costly in terms of storage at Amazon, or
> GitHub feared illegal content usage like with Mega Upload ?

That's probably the reality. It's a little irritating, but Github
pages are pretty easy to use and can host arbitrary stuff accessible
directly without https

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

steve donovan
In reply to this post by steve donovan
On Fri, Dec 28, 2012 at 11:19 AM, steve donovan
<[hidden email]> wrote:
> Cool, so I'll consistently use that.

Right! Next RC, no underscores (except function_arg, looks silly) Zip
at [1], updated docs at [2].

writefile() is indeed another useful little function. Toyed with
adding yet another optional argument to readfile() which would be the
argument you would pass to io.read, so 128 would read only those
bytes, '*l' would only read the first line, and so forth. But perhaps
we are getting into swiss army chainsaw territory.

Phillip Janda's exercises in functional composition have been very
helpful. His 'transmogrify' function is now here as imapfilter (and
aliased as Array.mapfilter).  It's a good match to the way Lua likes
to work, with functions returning either something useful or nothing.

    > = imapfilter(tonumber,{'one',1,'f',23,2})
    {1,23,2}

These are all built on the horribly general mapextend; not sure
whether this should be publically exported.


Array has been designed for extension, and has a mappers method for
creating map shortcuts (they actually use imapfilter which is a better
default)

    Strings = class(Array)

    Strings:mappers {  -- NB: note the colon: class method
        upper = string.upper,
        match = string.match,
    }

    local s = Strings{'one','two','three'}

    assert(s:upper() == Strings{'ONE','TWO','THREE'})
    assert(s:match '.-e$' == Strings{'one','three'})
    assert(s:sub(1,2):upper() == Strings{'ONE','TWO'})

Note the covariance of the sub method....

I've included a little script 'compress.lua' which knocks ml.lua down
from 28K to 13K; I intend to add extra annotations so that an
intelligent squisher tool would only link in the code that you use. So
if you just want a string splitter, then that will only add 12 lines
or so to your squished script.  Hard to do with general code without
heavyweight analysis, so I'll shape Microlight around this need.

steve d.

[1] http://stevedonovan.github.com/files/microlight-1.1.zip
[2] http://stevedonovan.github.com/microlight/

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

Dirk Laurie-2
> I've included a little script 'compress.lua' which knocks ml.lua down
> from 28K to 13K; I intend to add extra annotations so that an
> intelligent squisher tool would only link in the code that you use.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

Dirk Laurie-2
2012/12/31 Dirk Laurie <[hidden email]>:
>> I've included a little script 'compress.lua' which knocks ml.lua down
>> from 28K to 13K; I intend to add extra annotations so that an
>> intelligent squisher tool would only link in the code that you use.

[Ignore previous empty post]

The script would be well-positioned to do intelligent extraction.
I.e. certain named ML routines plus whatever they depend on
(local functions, upvalues (I hope not), other ML routines).
And intelligent exclusion, e.g.everything that does not require
ml.function_arg.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Microlight 1.1

steve donovan
On Mon, Dec 31, 2012 at 8:22 AM, Dirk Laurie <[hidden email]> wrote:
> The script would be well-positioned to do intelligent extraction.

Yes, exactly, particularly by exclusion. Hard to do this with
well-established libraries, but we can control ml (e.g. by not
depending on upvalues!)

The other part of the puzzle is more interesting; code analysis of
scripts so that a squisher has the information to extract the needed
code. Jay's Squish has two modes, static (byte code analysis) and
dynamic (tracking require calls).  So either we do metalua AST
analysis or code-coverage style debug function tracking.

But the payoff is a situation where a person can create a script which
only has exactly what they need, which means copy 'n paste reuse is no
longer needed.

steve d.