lua-users home
lua-l archive

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


On Thu, Jul 2, 2009 at 2:10 PM, Thomas Lauer<thomas.lauer@virgin.net> wrote:
>>   - Potential for confusion, maybe:
>>
>>       x:move (2, -3)
>>       object call: shortcut for x.move(x, 2, -3), x will be assigned to self
>>
>>     ..."x will be assigned to self", only if x.move was also created using the
>>     same syntax. Someone could misread this as 'whatever parameter was named
>>     "self", wherever it appears in the parameter list, will be set to x'.
>
> What wording would you propose instead? Perhaps removing the "x will be
> assigned to self" altogether?

I think so. I'd also specify in the "Function definition" section that self is
an extra *first* argument. (The reason I think that it is useful to
deconstruct the syntactic sugar a little bit here is that sometimes I want to
define a function inside a {} table literal, and of course in that situation
you have to add the "self" parameter explicitly.)

>>   - setmetatable and setfenv returns the table/function, I don't know if you'd
>>     consider this worth mentioning in this but I find it quite useful
>
> setmetatable: ack and changed.
>
> setfenv: the manual says "As a special case, when f is 0 setfenv changes
> the environment of the running thread. In this case, setfenv returns no
> values." So I'll leave it as it is.

True, I had forgotten about this extra complication.

Some additional notes:
  - Multi-line strings: One thing that is easy to forget is that if it starts
    immediately with a new line, that new line is removed. (You also don't
	mention the variable number of =s, but you do for multi-line comments,
	maybe this is deliberate.)
  - Decimal escape sequence can have one or two digits instead of three, again
    not mentioning this might be deliberate.
  - Very minor: "nil" not bolded in coroutine.running()
  - The __len metamethod is (currently) only used by userdata.

-Duncan