lua-users home
lua-l archive

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


How about this alternative (variation of code submitted by
Tom Miles):

function Position()
       return { 1,2 }
end

function Dimensions()
       return { 100,200 }
end

function push_clip(pos,dim)
       x, y = unpack(pos)
       w,h = unpack(dim)
       print(x,y,w,h)
end

push_clip(Position(), Dimensions())
-- prints:  1       2       100     200

This at least hides from the parent code details about what
Position() and Dimensions() are returning.

Mason Deaver

----------

Tom Miles wrote:

> function Position()
>        return x,y
> end
>
> function Dimensions()
>        return w,h
> end
>
> function push_clip(x,y,w,h)
>        -- Do stuff
> end
>
> push_clip(Position(), Dimensions())
>
> As it is, I have to do:
> local x,y = Position()
> push_clip(x,y, Dimensions())