I don't think Var was a good idea.

BlitzMax Forums/BlitzMax Programming/I don't think Var was a good idea.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

"That's Amon. I've only ever bought two Blitz products: B3D and BMax. And I sold my copy of B3D."


Hear that Weibo? I can be wrong!


Haramanai:
Honestly, no, because it's not really a "problem". I know how Var is used. I was only questioning how Mark chose to use it in the functions he provided with Blitzmax, and whether or not allowing Var to be used would lead to good programming practices.

I alrteady explained above, but I'll explain again.

If you have GetHandle() which returns to variables with Var, then you can't do this:

If (Image.X + GetHandleX()) > 0 then

Instead you have to create two temporary variables, pass them to GetHandle() and then do your if statement on one of them. It's a lot of extra work, just for the sake of having one GetHandle() function instead of a GetHandleX() function and a GetHandleY() function.

Granted, there might be some cases where using Var like this is more efficient. And maybe Mark is using it in a bad way and there are lots of good ways to use it. But if so, I can't think of many good ways to use it. And I am just worried that by having it available, people will misuse it just as Mark appears to have done.

Of course, some people might disagree with me that Mark has misused it at all. But as far as I'm concerned, if it makes more work for me, and makes me declare a bunch of extra variables to get the data, then it is a bad thing, until someone explains to me why it is otherwise.

Now, if I dig down into Max's source, I see that I might be able to do the following:

gc.Handle_X

So my handle example here might be a bad example, but Var is the subject not handle, and whether my handle example is good or not doesn't have bearing on how Var is or may be used.

Btw, I would personally not trust using gc.Handle_X myself. If it isn't in the docs, there's no guarantee it might not change. There is also no way to know if GetHandle() does something funny that needs to be done that just grabbing the handle like that won't do. Of course you can look at the code for GetHandle() to see that now maybe it doesn't do anyhting special. But who knows about later? If we're not intended to access it, and I take the docs to be the indicator of what is "finished" and intended to be accessed, I don't feel safe doing so. Also, a more important issue with that, is that users coming across that in my code won't be able to easily look it up to find out what it is doing, like they can with help file commands. That's a BIG problem. If the users of my code can't figure out what it is doing, that's bad. So I stick to the commands provided in the help file as much as possible. And that means being forced to use GetHandle(). Which means having to declare extra variables and getting the handle so I can add it to stuff, rather than just sticking GetHandleX() wherever I please. And that's annoying.

Hence my complaining.

But I really don't want to start this whole discussion over from scratch again. :-)