lua-users home
lua-l archive

Re: __index returns truncated to one, why?

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


2014年04月12日 15:24 GMT+02:00 duz <duz@sol-3.de>:
> Your arguments against my little proposal are valid when
> looking at tables. I don't think much of them applies to
> the userdata case but likely, nobody would be thrilled if
> metamethods worked subtlety different on different objects.
In the userdata case, metamethods are merely a way of
mapping object methods to Lua syntax. Unfortunately,
"one key, one value" is part of Lua syntax.
 var ::= Name | prefixexp ‘[’ exp ‘]’ | prefixexp ‘.’ Name
Your proposal exposes a gap if not an ambiguity in the 5.3
manual. The __index metamethod is a function, it must behave
exactly as rawgetting a table would — but it requires deduction.
almost reading between the lines, to extract that information.
The 5.2 manual was clear on the topic, giving pseudocode
for gettable_event. Maybe something like that could be
brought back.

AltStyle によって変換されたページ (->オリジナル) /