YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Use bitmasks instead of booleans
JayFoxRox
#1 Posted : Monday, July 15, 2013 8:16:05 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/15/2013(UTC)
Posts: 8
Location: Planet Earth

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I personally believe that the current squirrel API is not really readable in a few cases.

"sqstd_dofile(script->squirrelVm, _SC("script.nut"), SQTrue, SQTrue)"

for example would be more readable if it was:

"sqstd_dofile(script->squirrelVm, _SC("script.nut"), SQPushReturnValue | SQPrintErrors)"


As squirrel uses non stdbool or C++ booleans anyway it wouldn't be much different to have custom values to represent the different parameters. It would only make the code more readable.
Wether you check the documentation for the order of parameters or constant names doesn't really matter much. For intellisense it would even be easier if there was an enum with the bitmasks, solving the problem of order of parameters / finding parameter constant names and readability at once.

Thoughts?

fagiano
#2 Posted : Saturday, July 20, 2013 3:34:28 PM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 1,056

Thanks: 0 times
Was thanked: 78 time(s) in 60 post(s)
Yep you are right on this one. I'll might do an API refactoring at some point.

ciao
Alberto
Follow me on Twitter @squirrellang
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.064 seconds.