This is a bug. Tell me it isn't.
Blitz3D Forums/Blitz3D Programming/This is a bug. Tell me it isn't.
| ||
I was stumped why my code didn't work, even though the example code did. Then I finally found it:LinePick x1, 7, z1, 0, -10, 0 entitypicked = PickedEntity Do you see the problem? Here, let me write it the correct way: LinePick x1, 7, z1, 0, -10, 0 entitypicked = PickedEntity() Do you see the difference? The first example SHOULD NOT COMPILE if it won't work, but it does! Then you rip your hair out trying to figure out why it doesn't work. If a command requires parenthesis to actually work correctly then it should not compile without errors, DON'T YOU AGREE? |
| ||
Blitz allows variables and functions to have the same name. This, for example, works:PickedEntity = Rand( 1, 25 ) RuntimeError PickedEntity When Blitz sees PickedEntity without parenthesis, it sees a variable, not a function. |
| ||
Global Weeble# = 5 Function Weeble.Weeble() W.Weeble = New Weeble Return W.Weeble End Function Type Weeble Field Foobar End Type Ah, the miracles of nature. Or something. |
| ||
Is this C+ or Blitz??? (Whoops, **TYPO**, I meant C++) Think that's getting a little too syntactical (is that a word?). Keep it simple stupid. Allowing functions and variables to share names is just looking for headaches... |
| ||
not really. Just as a rule remember that funtions which return things have parentheses. So basically every function following = has parentheses. |
| ||
Not really. You can do this in a great deal of languages, some don't even distinguish the difference between a string, array, float, class, procedure, method, etc. (Ruby, for example, has 'dynamic data types' which means that I could reference an array at first, a file stream in the same variable next, and a class in the third [not like an object derived from a class, but an actual class definition]). It really is a good thing, you just have to be careful about typing function calls. |
| ||
Just as a rule remember that c++ increments after and ++c increments before. Just as a rule remember that = sets a variable and == compares a variable. Just as a rule remember that & means 'the address of' and * means 'pointed at by'. Just as a rule remember that . references the data member of an object and -> references the data member of an object with a pointer. Just as a rule remember... that the strict syntax is why I stopped using C++++. |
| ||
Global Weeble# = 5 Function Weeble.Weeble() W.Weeble = New Weeble Return W.Weeble End Function Type Weeble Field Foobar End Type You know Noel, this is exactly what you shouldn't be able to do. I almost can't understand that. It took me a bit to straighten it out in my head. |
| ||
WolRon: You can do it because you reference the type via .Weeble, the function via Weeble() (or in the case of not assigning a value to a variable, Weeble args), and the global as just plain Weeble or Weeble=<>etc. |
| ||
I understand why, I'm just saying that it's looking for problems. Typos are bad enough without the language allowing you to share names like that. |
| ||
/me stands in the center of the room and screams for case sensetivity. |
| ||
It isn't. |
| ||
Presumably B****M** (I dare not speak its name <g>) will eliminate this issue with its optional required declaration of variables. Back when I first learned Pascal two decades ago, I initially disliked its strongly typed variables and that it required declarations compared to the freedom of Basic variables, but those things do avoid problems like this and with typos. |
| ||
I've found one easy way to know when a function requires the parenthesis or not. When I use a function, I press F1 (when the cursor in on the name of the function). Then on the lower-left of the screen, the answer pops up. :-) |
| ||
Or, you could just remember that if you need something returned, you need perenthesis. It's really not that hard. You could even parenthesis everything regardless of whether you try to get a value from it. That's the safest way, I suppose. |
| ||
i find this feature useful! why is it so hard to get around? its a feature... but much required but still there.... |
| ||
I KNOW that functions returning values need to use parenthesis... the problem was that when I made a typo (which everyone will do now and then), the compiler didn't notify me that I did. Instead, it just assumed the command was a variable and continued on.,, Work smarter, not harder! I see little advantage gained by being able to use same name variables/functions considering the possibility for error. |
| ||
WolRon: Advantage: you can create functions that mimic the functionality of an object constructor. E.g. v.Vector = Vector(0,5,0) |