Issue #619 wontfix

Adding getLine and getPoint

hahawoo avatarhahawoo created an issue

So, I was always cool with getLine and getPoint (functions which would return both components of the state of lines/points) not existing, because there is already getLineStyle/Width and getPointStyle/Size. However, now I disagree with my past self and I think they should be added for these reasons:

1: It's probably nicer in practice. For example, one use for these getters which I assume could be quite common is for remembering the current state, changing stuff, then setting it back to the previous state.

Compare!

local style, width = love.graphics.getLineStyle(), love.graphics.getLineWidth()

-- Other stuff...

love.graphics.setLine(style, width)
local style, width = love.graphics.getLine()

-- Other stuff...

love.graphics.setLine(style, width)

It's now concise and symmetrical!

2: Less (things to remember) is more (good), and more (getters) is less (things to remember)!

Because almost all state which has a setter also has a getter, instead of remembering which states have getters, one remembers which states don't have getters. So adding getters for the setLine/setPoint setters actually reduces the complexity of the API IMO.

3: It's consistent with other functions which set/get more than one component of some state.

One possible objection to these getters could be that they're redundant because the information can be accessed with other getters. Also, I used to think that setLine/setPoint should actually be removed, because their names are a bit confusing and they're also redundant.

However, when there is a state which has multiple components and is conceptually about the same thing (color, window mode, filter modes, source volume limits, etc.), there seems to always be a setter/getter for setting/getting all of the components, and then setters/getters for individual components only if they're especially useful (such as love.graphics.getWidth/Height).

Another possible objection (maybe, I dunno :D) could be that it's not obvious what the functions would return and in what order, however this could be said for the setter functions too, and any other functions which sets/gets multiple components. Also, the symmetry with setLine/Point should make this more obvious.

Comments (2)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.