XML talk:BINA/OBJC/TRGV: Difference between revisions

m
no edit summary
(re-sigh)
mNo edit summary
Line 40: Line 40:
I have confirmed in my own way that the strings coming from runtime events are (apparently) compared by pointer rather than by content. Suppose you define two global string vars, '''dead_name''' and '''dead_name_too'''. Then you kill '''A_t48'''  twice (after force-spawning him), with '''t48_dead(string ai_name)''' performing the assignment '''dead_name = ai_name'''. Between the two deaths, do '''dead_name_too = dead_name''' from the console (this is now a redirect to the same string data, and '''dead_name_too eq dead_name''' evaluates to '''true'''). After the second A_t48 death, try '''dead_name_too eq dead_name''' again, and see that it evaluates to '''false''' now (there used to be one string, and now it's two identical strings at different addresses). --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 13:10, 18 May 2020 (CEST)
I have confirmed in my own way that the strings coming from runtime events are (apparently) compared by pointer rather than by content. Suppose you define two global string vars, '''dead_name''' and '''dead_name_too'''. Then you kill '''A_t48'''  twice (after force-spawning him), with '''t48_dead(string ai_name)''' performing the assignment '''dead_name = ai_name'''. Between the two deaths, do '''dead_name_too = dead_name''' from the console (this is now a redirect to the same string data, and '''dead_name_too eq dead_name''' evaluates to '''true'''). After the second A_t48 death, try '''dead_name_too eq dead_name''' again, and see that it evaluates to '''false''' now (there used to be one string, and now it's two identical strings at different addresses). --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 13:10, 18 May 2020 (CEST)


It should be noted, however, that "ordinary" string literals (the ones that are included in BSL scripts and allocated at level start) seem to be always compared by content even if they're changed to completely new literals at runtime (as long as it's from the console). If you have two global string vars '''testVar''' and '''testVar2''', you can set them both to "bla" from the console, and '''testVar eq testVar2''' will evaluate as '''true''' - so apparently the comparison becomes lazy (by pointer) if at least one of the strings (pointers) is in the dynamic range used by runtime events, but for new strings from the console (also dynamically allocated) it still uses the non-lazy comparison. --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 13:10, 18 May 2020 (CEST)
It should be noted, however, that "ordinary" string literals (the ones that are included in BSL scripts and allocated at level start) seem to be always compared by content even if they're changed to completely new literals at runtime (as long as it's from the console and not from OBJC events). If you have two global string vars '''testVar''' and '''testVar2''', you can set them both to "bla" from the console, and '''testVar eq testVar2''' will evaluate as '''true''' - so apparently the comparison becomes lazy (by pointer) if at least one of the strings (pointers) is in the dynamic range used by runtime events, but for new strings from the console (also dynamically allocated) it still uses the non-lazy comparison. --[[User:Geyser|geyser]] ([[User talk:Geyser|talk]]) 13:10, 18 May 2020 (CEST)