lua-users home
lua-l archive

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


It was thus said that the Great Soni L. once stated:
> 
> >   To me, upvalues as part of a function signature reminds me of making
> >exceptions part of the function signature in Java---it may be a nice idea 
> >to
> >be explicit about such things, but it gets annoying quite fast (and you get
> >aorund it by subclassing RuntypeException).  It would also seem to be
> >repeating yourself in code quite often.
> >
> local function f() <>
>   return function() -- no _ENV in enclosure, no _ENV in function
>     return x -- error, no _ENV
>   end
> end

  Wouldn't this need to be?

	local function f() <>
	  return function()<>
	    return x
	  end
	end

And this brings up another point:

	local print = print
	local cache = {}

	local function f()
	  return function(key) <print,cache>
	    print("DEBUG: key is ",key)
	    return cache[key]
	  end
	end

Or should it be:

	local function f() <print,cache>
	  return function(key) <print,cache>
	    print("DEBUG: key is ",key)
	    return cache[key]
	  end
	end

I could make an argument for both cases.  And is this for safety, or for
easy of serialization?

  -spc