User bio
404 bio not found
Member since Dec 9, 2015
Replies:

With all due respect, Python, C#, Java, Rust, and other languages also allow multiple commands on the same line just like ObjectScript does. I see that Go doesn't allow this.

ObjectScript simply evaluates expressions (arithmetic and logical) strictly left-to-right. Using parentheses gives you control, and has the added benefit of making a complex expression easier to read for other developers. Would you ever write this in any language?

if a = 3 && b = 4 && c = 5 || d = 6 {write "succeeded"} else {write "failed"}

No. You'd write it like this:

if (a = 3) && (b = 4) && ((c = 5) || (d = 6)) {write "succeeded"} else {write "failed"}

Please avoid using the legacy single-line If and Else commands. Needing to use 2 spaces after the Else is confusing at best and causes problems at worst. If you want a single line If, this is fine:

if option1 { do ##Class(Features.Option1).DoSomething() }

A developer will quickly understand the code above and it's straightforward to modify it if more code needs to run based on the condition, or if an Else needs to be added.

On the topic of post-conditionals supposedly being confusing, other languages have similar things ("ternary operator"):

set w = "goodbye" set:(z < 5) w = "hello"
w = "hello" if z < 5 else "goodbye"
w = (z < 5) ? "hello" : "goodbye"
Open Exchange applications:
Certifications & Credly badges:
Joel has no Certifications & Credly badges yet.
Followers:
Following:
Joel has not followed anybody yet.