[Not a bug] The ?: operator

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
Nanami
Posts: 1066
Joined: Tue Jul 15, 2003 5:13 pm
Location: That little island pritch created.
Contact:

The ?: operator

Post by Nanami »

Okay this isn't a bug, but I thought I'd get Randy's attention easier this way. =P

ACS doesn't support the ?: operator, unless I'm using it wrong:

Code: Select all

(laps == 1)?
     HudmessageBold(s:"1 lap to win.";2,1,9,0.5,0.5,1.0):
     HudmessageBold(d:laps,s:" laps to win.";2,1,9,0.5,0.5,1.0);
This is probably nothing anyone but me cares about, and I've no idea how easy/hard this would be to add. Just thought I'd bring it up. Cheers.
User avatar
Eevee
Posts: 592
Joined: Wed Jul 16, 2003 5:26 am
Contact:

Post by Eevee »

usually ?: is used as part of an expression, not just as a lazy way to write an if o.o but I wouldn't be surprised if it's not supported...
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

She's not using it in the manner you describe.

If laps == 1, the first Hudmessage will be called. Otherwise, the second is called. This is the intended usage.

It's actually more typical to use it in an assignment clause though, like this:

x = (laps == 1) ? 7 : 3
Cyb
Posts: 912
Joined: Tue Jul 15, 2003 5:12 pm

Post by Cyb »

acs doesn't support ?:

for the love of god just use a freaking if clause

?: only exists in C because the original intents for the language was to be for low-level systems programming without having to use ASM or machine language. ?: is faster than if() (to the best of my knowledge), and speed it often an issue with C. It's hardly worth having in ACS because a) it hurts readabilty and b) ACS is interpreted and thus slow by definition :P
User avatar
randi
Site Admin
Posts: 7746
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Post by randi »

Everything you can do with ?:, you can do with if/else. If the ACC parser was automatically generated from a formal grammar, I would have added ?: long ago since it would have been an easy addition.

But it's not, and this doesn't qualify as important enough for me to fit a trinary operator into its hand-coded parser.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

randy wrote:Everything you can do with ?:, you can do with if/else. If the ACC parser was automatically generated from a formal grammar, I would have added ?: long ago since it would have been an easy addition.

But it's not, and this doesn't qualify as important enough for me to fit a trinary operator into its hand-coded parser.


Fully understandable. I tried to mess with the parser once and I have to confirm that it's no fun to do so.
Post Reply

Return to “Closed Bugs [GZDoom]”