[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Safe navigation operator
- From: Cuero Bugot <cbugot@...>
- Date: Mon, 23 Aug 2010 05:45:25 -0700
> > local emptytable = {}
> > local function Opt (t) return t or emptytable end
> >
> > if config.Opt(network).Opt(server).url then
> > dosomething(config.network.server.url)
> > End
> That does not make any sense. I do not know what I was thinking. Sorry
> for the noise...
Well at least it illustrate what I meant by 'context'. Opt() is "in the middle path/table traversal" while the last ".url" is "the final access". If metamethods __index / __newindex did provide this kind of information then it would be easy to implement safe navigation operator with metatables
Would that be something completely unrealistic to provide more contextual information as parameters of the __index / __newindex metamethods ?