Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

My lambda is calculating

Name: Anonymous 2012-09-01 13:42

I must fork all of the glibc versions before I go completely academic

I can't even stand non-LISPs' lack of first class and anonymous functions anymore ;_;

Name: Anonymous 2012-09-01 15:41

>>4
lua is just a little bit more far out than javascript.


function caching_inherit(self, ...)
  local parent_classes = {...}
  local cache = {}
  local meta = {__index = function(self, k)
                  local cached_value = cache[k]
                  if cached_value ~= nil then
                    return cached_value
                  else
                    for _, parent_object in ipairs(parent_classes) do
                      local parent_value = parent_object[k]
                      if parent_value ~= nil then
                        cache[k] = parent_value
                        return parent_value
                      end
                    end
                  end
                end}
  setmetatable(self, meta)
  return self
end

A = {a='A.a', b='A.b', c='A.c'}
B = {b='B.b', x='B.x'}
C = {c='C.c'}

X = caching_inherit({x='X.x'}, B, C, A)

print('X.a == ', X.a)
print('X.b == ', X.b)
print('X.c == ', X.c)
print('X.x == ', X.x)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List