957 posts
Location
Web Development
Posted 18 January 2016 - 02:33 AM
Anyone who as accidentally passed a value other than a number to term.setCursorPos has probably encountered this problem:
An error in a file that seems to have no correlation with your program.
On one hand, anyone who knows
the window API will immediately realize their mistake, and hunt down the function call with incorrect arguments.
But on the other hand, it is still really annoying. For everyone involved.
And you can prevent it with a single line:
function window.setCursorPos( x, y ) --# Line 232
if type( x ) ~= "number" or type( y ) ~= "number" then error("expected number,number, got "..type(x)..","..type(y) , 2) end
nCursorX = math.floor( x )
nCursorY = math.floor( y )
if bVisible then
updateCursorPos()
end
end
Edited on 18 January 2016 - 01:33 AM
7083 posts
Location
Tasmania (AU)
Posted 18 January 2016 - 06:46 AM
A lot more checks could go into the window API. They'd come at the cost of speed for all users, though, and would only benefit those using it incorrectly. I personally lean towards encouraging coders to learn how to dig into an external API and figure out their own mistakes.
957 posts
Location
Web Development
Posted 18 January 2016 - 07:16 AM
A lot more checks could go into the window API. They'd come at the cost of speed for all users, though, and would only benefit those using it incorrectly. I personally lean towards encouraging coders to learn how to dig into an external API and figure out their own mistakes.
True, it might slow down things a bit. What about a setting that switches between two versions of the api, one that does error checking, so you can debug your program, and one that doesn't, for speed?
Edited on 18 January 2016 - 06:19 AM
7083 posts
Location
Tasmania (AU)
Posted 18 January 2016 - 08:52 AM
Since you mention it, there's this great new setting for toggling multishell… :)/>
724 posts
Location
Kinda lost
Posted 18 January 2016 - 08:55 AM
True, it might slow down things a bit. What about a setting that switches between two versions of the api, one that does error checking, so you can debug your program, and one that doesn't, for speed?
For me that sounds like a fun project for someone to make a debug version of window api.
957 posts
Location
Web Development
Posted 18 January 2016 - 09:02 AM
Since you mention it, there's this great new setting for toggling multishell… :)/>
Would turning off multishell also turn of the window API? That would be really convenient ;)/>
7083 posts
Location
Tasmania (AU)
Posted 18 January 2016 - 09:13 AM
Would turning off multishell also turn of the window API? That would be really convenient ;)/>
The API would still be loaded and ready to use, it just wouldn't go between you and all your term calls unless you yourself coded things that way.