getPoints pushes values onto stack

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
kaishaku
Prole
Posts: 14
Joined: Sun Aug 31, 2008 10:42 pm

getPoints pushes values onto stack

Post by kaishaku »

It might be good to document that getPoints does not return a table.

If this is a common convention in the Love API perhaps an explicit technique would be better.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: getPoints pushes values onto stack

Post by rude »

Yes, this allows you to pass the values directly to love.graphics.polygon.
User avatar
BlackNecro
Prole
Posts: 2
Joined: Fri Aug 29, 2008 2:09 pm

Re: getPoints pushes values onto stack

Post by BlackNecro »

Wouldn't a table be easier to handle and if you would want to pass it to the polygon function just use love.graphics.polygon(drawtype,unpack(pointtable))?
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: getPoints pushes values onto stack

Post by rude »

Well ... I guess, if enough people think so.

My reasoning was that it would be much slower to construct a table and unpacking it again before sending it to love.graphics.polygon. You can still pack the values:

Code: Select all

t = { p:getPoints() }
We could add p:getPointsTable(), and enjoy BOTH variants.
kaishaku
Prole
Posts: 14
Joined: Sun Aug 31, 2008 10:42 pm

Re: getPoints pushes values onto stack

Post by kaishaku »

EDIT: Removed. Didn't pay attention to previous code:

Code: Select all

t = { p:getPoints() }
This is good. Maybe the name "getPoints" is a problem though, particularly if there are more like this.

For the record, an array userdata may be a solution for future table<->array interop dilemmas.
The book uses exactly that for its userdata examples: http://www.lua.org/pil/28.1.html
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests