[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Weak keyed tables with primitive keys
- From: Mark Hamburg <mark@...>
- Date: Tue, 20 Oct 2009 22:21:34 -0700
I understand the theoretical arguments for treating strings as values
with respect to weak tables, but are there any practical benefits? It
would seem, for example, to get in the way of caching the results of
file reads a la:
fileCache = setmetatable( { }, {
__mode = 'kv',
__index = function( t, k )
local v
local f = io.open( k )
if f then
v = f:read( "*a" )
t[ k ] = v
f:close()
end
return v
end } )
Mark