Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008421opensim[REGION] Scripting Enginepublic2018-12-10 07:202018-12-11 08:49
Reporterunregi 
Assigned Tomelanie 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusresolvedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0008421: [YEngine] Evaluation order of logical operators right to left or left to right :)
DescriptionIn XEngine, && and || got executed from left to right, in YEngine, it's right to left. This breaks some of our satyr farm scripts now, because i used a while like in that example below to imitate a case-insensitive llListFindList (i know, i know, could have written it different).

In SecondLife it's (according to the wiki) also right to left, here the section:

Note: The order of precedence of boolean operators is unclear. It is possible that there is a bug in the expression parser, making precedence inconsistent, or it may simply be that || and && have equal precedence; testing is inconclusive. Thus, when in doubt, parenthesize. SubNote: As the above bug has been closed as expected behavior, one can only assume the boolean operators have equal precedence.
Note: The order of evaluation appears to be backwards from most languages. If the value of x starts as 1 then the first two conditions below evaluate false and the second two evaluate true:
(x && (x = 0) == 0 && x)
(x && (x = 0) == 0 && x == 0)
(x == 0 && (x = 0) == 0)
(x == 0 && (x = 0) == 0 && x)
http://wiki.secondlife.com/wiki/LSL_Operators [^]


I would just like to have the opinion from core, if it's going to stick with right-to-left for SecondLife compatibility now or if it will got back to XEngine behaviour for backwards compatibility.
Steps To ReproduceScript to test:

integer say(string text)
{
    llSay(0, text);
    return 0;
}

default
{
    touch_end(integer num)
    {
        list test = ["a", "b", "c", "d"];
        string search = llToUpper("C");
        integer length = llGetListLength(test);
        while (length-- && llToUpper(llList2String(test, length)) != search);
        llSay(0, search + " on position " + (string)length);
        
        if (say("1") && say("2"));
        
        if (say("1") || say("2"));
    }
}
TagsNo tags attached.
Git Revision or version number
Run Mode Grid (1 Region per Sim)
Physics EngineBulletSim
EnvironmentMono / Linux64
Mono Version5.x
Viewer
Attached Files

- Relationships

-  Notes
(0033604)
melanie (administrator)
2018-12-11 06:35

XEngine had it wrong because I could not back then replicate SL behaviour. The language is definitely specified as RTL collation and we should not break a finally correct engine to replicate a bug.
(0033607)
unregi (reporter)
2018-12-11 07:57

Got it, so i will rewrite my stuff so that evaluation order doesn't matter, to not break compatibility.
(0033608)
UbitUmarov (administrator)
2018-12-11 08:49

try to write code less dependent on the engine

if(blabla == NULL_KEY) will work anywhere

if(blabla) will not.

- Issue History
Date Modified Username Field Change
2018-12-10 07:20 unregi New Issue
2018-12-10 07:21 unregi Steps to Reproduce Updated View Revisions
2018-12-11 06:35 melanie Note Added: 0033604
2018-12-11 07:57 unregi Note Added: 0033607
2018-12-11 07:58 melanie Status new => resolved
2018-12-11 07:58 melanie Resolution open => no change required
2018-12-11 07:58 melanie Assigned To => melanie
2018-12-11 08:49 UbitUmarov Note Added: 0033608


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker