Closed ZiwKerman closed 9 years ago
Are you aware that "ALT:RADAR" isn't a real suffix (there is no "ALT" object) and instead there's a tricky alias where when you type ALT:RADAR it turns it into ALT_RADAR"?
So saying LOCK ALT_RADAR TO ALT:RADAR is effectively infinite recursion of the form LOCK A TO A.
I was going to mark this as not-a-bug but then I realized... maybe it might be possible to detect the LOCK A TO A case in the compiler. I could set a variable curLockName
to the identifier's name when compiling the lock's expression, and have it throw an error when it notices that you are trying to use that identifier name somewhere inside the expression.
For some reason the lock alone does not produce overflow, only when you try to pass it as a parameter
so this code lock alt_radar to alt:radar
executes without any problems
I see nowhere in your code where function foo() actually gets called.
hmm, even calling non-existent funstion ar
causes overflow
That's because you never got that far. First it evaluates that arguments, puts the result on the stack, THEN calls ar(). It never got far enough to tell that ar() isn't a function because it hit the infinite recursion when trying to eval alt_radar to get the argument ready.
You'd have had the same problem if you did anything else with alt_radar:
[code] lock alt_radar to alt:radar. print alt_radar. [/code] Would do it too.
So ALT_RADAR isn't a valid identifier. 1) Is it documented? 2) What is the reason behind doing it this way? Why can't we use something that isn't a valid kerboscript identifier in cases like this?
1) I hate the fact that ALT:RADAR is fake alias for ALT_RADAR. It's not my decision to do it that way. That's very old original design and now hard to change without breaking everything.
2) Because you have to be able to use LOCK on bound variables. i.e. LOCK THROTTLE.
It may be possible to add more checks to detect if a bound variable is get-only and not allow it in a lock.
Could you change alt
to be a structure or at least alt:radar
to be an alias to alt-radar
along with next ksm-breaking update?
That may be possible. The use of ALT_RADAR was never documented so the fact that it works was never made into a public promise. (Although I did use it in my hover PID example because I didn't realize it was undocumented - I should go fix that).
Making alt
a structure will enable people to pass it as a parameter, a return value, or just assign it to a variable. Don't know is it useful or not.
How many other implicit aliases like ALT_RADAR are out there?
@abenkovskii the only one i know of is ETA
@erendrake What about VERSION?
@abenkovskii nope, VersionInfo is a structure
If you're talking about fixing alt:radar we should fix the fact that it's presumed to only work on the current ship. You can get target:altitude but not target:alt_radar.
I am of the opinion that ALL the shorthands like ALTITUDE, PROGRADE, etc, need to be aliases to SHIP:thingy. Many are , but alt radar is one of the holdouts.
after my other fix, does this still happen? Can it be closed?
ar(alt_radar).
is supposed to be foo(alt_radar).
This issue is fixed now.
Log: