Page 1 of 1
getPoints pushes values onto stack
Posted: Mon Sep 01, 2008 3:31 am
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.
Re: getPoints pushes values onto stack
Posted: Mon Sep 01, 2008 1:22 pm
by rude
Yes, this allows you to pass the values directly to love.graphics.polygon.
Re: getPoints pushes values onto stack
Posted: Mon Sep 01, 2008 3:46 pm
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))?
Re: getPoints pushes values onto stack
Posted: Mon Sep 01, 2008 3:58 pm
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:
We could add p:getPointsTable(), and enjoy BOTH variants.
Re: getPoints pushes values onto stack
Posted: Mon Sep 01, 2008 4:36 pm
by kaishaku
EDIT: Removed. Didn't pay attention to previous code:
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