lua-users home
lua-l archive

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


2013/12/15 Sir Pogsalot <sir.pogsalot@gmail.com>:

> My approach instead goes for tracking object identity (which
> I believe to be the more correct approach), by converting each
> object to a tracked id number.

The name 'serialize' may be misleading. It can be any many-to-one
function f with the property that f(a1,a2,...,an)==f(b1,b2,...,bn)
if and only if a1==b1, a2==b2, ..., an==bn, including your
concatenation of tracking numbers.

So I've modified your module so that the returned table also provides
`serialize = args_to_str` and used that in my version of ml.memoize.

I note that e.g. serialize{1,2,3,4} gives a different tracking number
at each call but serialize(tbl) gives the same tracking number even
if the contents of tbl is no longer the same. The opposite, in fact,
to what a standard serializer like the one in PiL or those on the
Wiki would do.

This brings me back to the point that drove Petite Abeile's head
to explode: if the contents of a table `tbl` has changed, do we
want a memoized function to still return the value from the
last time that `tbl` was the argument?

Is doing so really "the more correct approach"?