Open slime73 opened 6 years ago
Original comment by itraykov (Bitbucket: itraykov, GitHub: itraykov).
love.graphics.text isn't very descriptive, it's usually better to use (short) verbs to describe functions, so possibly love.graphics.write or something like that.
Furthermore, I have a question regarding love.graphics.printf: https://love2d.org/forums/viewtopic.php?f=4&t=84764 Nobody on the forums can confirm this: Does love.graphics.printf support RTL languages? Or does it always wrap text from the right side?
Original comment by Jeroen_Tricky_Broks (Bitbucket: Jeroen_Tricky_Broks, ).
For me the purpose of love.graphics.print was very clear from the start when I saw it in the command summary. All I needed to know next was which parameters it took (and in which order). When it comes to console features, it's already there, then it's just "print" which is by the way just an internal Lua feature and not specific to LÖVE.
Now I am heavily against renaming the function. I don't think "text" or "drawtext" is any less confusing than "print", not to mention that "print" is a very much used command. Although there might be some people who only use print for debugging purposes, even then the command is used. I don't wanna dare to imagine to total lines of code that will have to be changed because of that.
Of course, Lua is a language that can be used the dirty way. If love.graphics.print bothers you so much, why not put in the line "text=love.graphics.print" on top of your program? I've used that trick on countless love commands out of pure laziness as I always fall asleep by the time I typed something like "love.graphics.setColor(a,b,c)", so with a simple "color=love.graphics.setColor" I could now type "Color(a,b,c)".... Easy, huh?
In a certain way "love.graphics.print" is true to its name. It PRINTS text onto the screen/window. Some older gaming languages I've examined have a similar function called "PRINTXY". In the history of programming (Hey, I've been along in programming since 1983, mind you), PRINT has never been solely reserved for command-line console uses, you know :P
Original comment by hahawoo (Bitbucket: hahawoo, GitHub: hahawoo).
@itraykov, I think love.graphics.text
is descriptive because it draws text, and most of the other functions which draw to the screen aren't verbs, e.g. love.graphics.rectangle
.
@Jeroen_Tricky_Broks, do you know of any other current game framework or engine that uses the word "print" in this way?
Here is what I have found:
Original report by hahawoo (Bitbucket: hahawoo, GitHub: hahawoo).
(I kind of brought some of this up in an older issue along with some other stuff, and I feel bad for posting it here again especially if it was already considered and rejected, but I just wanted to make a proper case for it, even if it's a bad idea.)
love.graphics.print
doesn't output to console (like Lua'sprint
), it draws text.(If LÖVE did have a function which output to console for some reason, this might be a good name, although not in the graphics module.)
love.graphics.printf
doesn't output to console and it doesn't do string formatting (like its namesake, C'sprintf
, or Lua'sstring.format
), it draws text wrapped and aligned within a given width.One might think "but
love.graphics.printf
does print formatted text", however I believe one would be using different definitions of "printing" and "formatting" than its namesake, which is kind of weird.I think that they could be named after what they do more accurately, like
love.graphics.text
andtextWrapped
orformattedText
or something, I don't know.However,
print
andprintf
are clever names IMO in their recontextualizations of the terms, and they're short names too, and of course they have the benefit of already being the names.