sorcery  Diff

Differences From Artifact [d4f49ab351]:

To Artifact [d54be79f29]:


   180    180   end
   181    181   
   182    182   fn.proto = function(tbl,proto)
   183    183   	local meta = getmetatable(tbl)
   184    184   	local nm = {__index = proto or tbl}
   185    185   	if meta ~= nil then
   186    186   		nm = table.copy(meta)
   187         -		nm[__index] = proto
   188         -		nm[__metatable] = meta
          187  +		nm.__index = proto
          188  +		nm.__metatable = meta
   189    189   	end
   190    190   	return setmetatable(tbl or {},nm)
          191  +end
          192  +fn.defaults = function(dft, tbl)
          193  +	tbl = tbl or {}
          194  +	local rp = {}
          195  +	for k,v in pairs(dft) do
          196  +		if tbl[k] == nil then rp[k] = v end
          197  +	end
          198  +	return fn.proto(rp, tbl)
   191    199   end
   192    200   
   193    201   fn.case = function(e, c)
   194    202   	if type(c[e]) == 'function'
   195    203   		then return (c[e])(e)
   196    204   		else return c[e]
   197    205   	end