set: share metatable so that __le and __lt work.

* specs/set_spec.yaml: Many more examples, in particular to check
behaviour of __le and __lt comprehensively.
* lib/std/set.lua (metaset): New metatable shared by all sets.
(new): Adjust.
* NEWS: Update.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
object: fix __lt and __le support with shared metatables.

* specs/object_spec.yaml: Specify desired behaviour with new
examples for metatable sharing.
* lib/std/object.lua (metaentry): New helper function.
(object_type, clone, stringify, totable): Factor out of root
object initialiser.
(clone): Maintain separation between "_" prefixed fields, kept
in the new object metatable, and everything else in the object.
If the newly instantiated object requires a new metatable to
support the additional "_" prefixed keys, create it, otherwise
share the prototype's metatable.
Additionally, when creating a new metatable, be sure to merge
in __index methods from the prototype metatable.
(Object): Much simplified!
(metatable): Set type, methods and metamethods for root object.
* lib/std/list.lua (methods, metalist, new): Refactored from
these...
(List, new): ...to these, also simplifed accordingly.
* lib/std/set.lua (M, metaset, new): Refactored from these...
(M, new): ...to this, much simplified.
* specs/list_spec.yaml, specs/set_spec.yaml: Add more examples
to specify metatable propagation behaviour, and refactor for
clarity and consistency.
* NEWS: Update.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
object: be consistent with various object constructors.

* specs/object_spec.yaml: Specify behaviour for Object:clone {}
and object.new () constructors, with single table initialiser and
parameter list respectively, plus the Object {} and object ()
syntactic sugars for each.
* specs/list_spec.yaml, specs/set_spec.yaml,
specs/strbuf_spec.yaml: Likewise for other objects to make sure
all are consistent.
* lib/std/list.lua, lib/std/set.lua, lib/std/strbuf.lua: Implement
the specified behaviours.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
object: don't assume object metatable __index is always a table.

* lib/std/object.lua (clone): Only merge new object metatable
methods when both metatables have a table type __index entry.
(metatable:__call): Let Lua do the lookup for an object clone
function, incase __index is a function.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
object: std.object returns the root object.

Fix some latent bugs caused by the artificial separation between
the metatable of object and object.Object, by removing the
distinction between the two.  `require "std.object"` returns the
actual root object, ready to go!
* specs/object_spec.yaml: Remove examples of constructing an
object from the object module table and the `new` method.
* lib/std/object.lua: No need to wrap the root object in an
additional layer of abstraction to return a module table containing
the root object.  Just return the root object directly.
(object.new): Remove.
Adjust all callers.
* NEWS: Update.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
set: std.set returns the Set prototype object.

Fix some latent bugs caused by the artificial separation between
the metatable of set and set.Set, by removing the distinction
between the two.  `require "std.set" returns the actual Set object,
ready to go!
* specs/set_spec.yaml: remove examples of constructing a set from
the module table, and with the `new` command.
* lib/std/set.lua: No need to wrap the Set prototype in an
additional layer of abstraction to return a module table containing
the Set prototype.  Just return Set directly.
(set.new): Remove.
Adjust all callers.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
strbuf: std.strbuf returns the strbuf prototype object.

Fix some latent bugs caused by the artificial separation between
the metatable of strbuf and strbuf.StrBuf, by removing the
distinction between the two.  `require "std.strbuf"` returns the
actual StrBuf object, ready to go!
* specs/strbuf_spec.yaml: Remove examples of constructing a StrBuf
from the module table, and with the `new` command.
* lib/std/strbuf.lua: No need to wrap the StrBuf prototype in an
additional layer of abstraction to return a module table containing
the StrBuf prototype.  Just return StrBuf directly.
(strbuf.new): Remove.
Adjust all callers.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
list: std.list returns the List prototype object.

Removing the separation between List prototype and the module
table that used to wrap it, for consistency with the other
Object specialisations.  We break backwards compatibilitf here
though because the argument ordering used to be different for
several functions depending on whether they were called through
the module table, or as List methods.  The List method ordering
(i.e. list argument first) wins out here, because that is a
prerequisite of being able to call object methods with the Lua
: syntax.
* specs/list_spec.yaml: Remove examples of constructing a List
from the module table, and with the `new` command.
* lib/std/list.lua: Much simplified by removal of the module
table.
(filter, foldl, foldr, index_key, index_value, map, map_with)
(project, shape, zip_with): The list operand is always first
now, whether called with a `.' or a `:'.
Adjust all callers.
(new): Remove.  Adjust all callers.
* NEWS: Update.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>