lua-users home
lua-l archive

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

2015-08-21 4:18 GMT+02:00 Sean Conner <>:

> 1) Allow unique metatables for lightuserdata, that also respect __gc.  This
> would allow for cheaper creation of datatypes that are managed outside of
> Lua.  For my xlib interface [1] it would keep me from having to create full
> userdata that's just a pointer to a pointer.

In the parent thread, Roberto made a suggestion that can
be interpreted (and I did) as allowing per-item metatables
for all values, regardless of type, and scrapping the present
metatable pointers in the table and userdata structures.

Respecting __gc is an unreasonable demand in that case.

-1 to this one, +1 to Roberto's idea.

> 2) Allow a method to create new literals.  Here me out.  If we do this, and
> set up some way of writing code to understand literals, then we can pull
> strings out of the core and into an actual module.  Really, the only
> difference between a string and a userdata is that there's support for
> string literals in core.

+0.5 to this one, i.e +1 for this half of it only. It can be implemented
in a less revolutionary way than suggested in the other half.

Use sharp brackets as delimiters for a string that will be
tested in order against already-defined patterns until one
matches, creating a table with a metatable which has been
associated with that pattern.

date = <2015-08-21>
date.year --> 2015
-- you get the drift

> Let's see ... modify the parser such that when it encounters a character
> it doesn't understand, or in a context it doesn't make sense, call a
> function (supplied by the user) to pick up parsing and return some actual
> value.

Too general. The resulting code need no longer look like Lua.
It can be Brainfuck or Malebolge, whatever.