secondlife / jira-archive

2 stars 0 forks source link

[BUG-234143] Conditional Operator Expressions In LSL #11119

Open sl-service-account opened 1 year ago

sl-service-account commented 1 year ago

How would you like the feature to work?

Instead of:


string bool = "False";

if( someInteger == TRUE )
{
    bool = "True";
}

llOwnerSay( "someInteger is " + bool );

We could simply do:


llOwnerSay( "someInteger is " + ( someInteger == TRUE ? "True" : "False" ) );

Why is this feature important to you? How would it benefit the community?

This can increase code readability and (possibly) decrease LSL bytecode? This would be amazing to have. These are in almost every language used today. C-Sharp, Javascript, C, C++, etc ...

Original Jira Fields | Field | Value | | ------------- | ------------- | | Issue | BUG-234143 | | Summary | Conditional Operator Expressions In LSL | | Type | New Feature Request | | Priority | Unset | | Status | Accepted | | Resolution | Accepted | | Created at | 2023-07-18T07:44:33Z | | Updated at | 2023-07-19T17:41:43Z | ``` { 'Build Id': 'unset', 'Business Unit': ['Platform'], 'Date of First Response': '2023-07-18T11:36:39.229-0500', 'How would you like the feature to work?': 'Instead of:\r\n{code:lsl}\r\nstring bool = "False";\r\n\r\nif( someInteger == TRUE )\r\n{\r\n bool = "True";\r\n}\r\n\r\nllOwnerSay( "someInteger is " + bool );\r\n{code}\r\n\r\nWe could simply do:\r\n{code:lsl}\r\nllOwnerSay( "someInteger is " + ( someInteger == TRUE ? "True" : "False" ) );\r\n{code}', 'ReOpened Count': 0.0, 'Severity': 'Unset', 'Target Viewer Version': 'viewer-development', 'Why is this feature important to you? How would it benefit the community?': 'This can increase code readability and (possibly) decrease LSL bytecode? This would be amazing to have. These are in almost every language used today. C-Sharp, Javascript, C, C++, etc ...', } ```
sl-service-account commented 1 year ago

Peter Stindberg commented at 2023-07-18T16:36:39Z

Doesn't increase readibility for me, but my formal training happened in the Eighties and we didn't had anything fancy back then.

Assuming LSL is a language a lot of programming-laypersons learn, the classic way to write it is way more readable, than the shortened version you suggest.

It shouldn't decrease the bytecode if the compiler is any good. Both versions should compile to the exact same bytecode. Should.

sl-service-account commented 1 year ago

JIRAUSER341305 commented at 2023-07-19T06:00:44Z

Talking about readability then…  The question becomes, how it compares to how many of us actually write that;


llOwnerSay( "someInteger is " + llList2String(["True", "False"], !someInteger) ); 

Compared to that, the ternary operator is probably the better choice.

sl-service-account commented 1 year ago

Spidey Linden commented at 2023-07-19T17:41:39Z

Issue accepted. We have no estimate when it may be implemented. Please see future release notes for this fix.