Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Cuttlefish
Apprentice


Joined: 28 Oct 2003
Posts: 164

PostPosted: Mon Nov 17, 2003 8:23 am   

suggestion to clarify | in expressions helpfile
 
#if (0|0) {#show "match"} {#show "nomatch"}
> prints "match"

#if (0 | 0) {#show "match"} {#show "nomatch"}
> prints "nomatch"

#if (0&0) {#show "match"} {#show "nomatch"}
> prints "nomatch"

Just thought there should be some clarification in the helpfile that you have to put a space on either side of the pipe. This isn't true for &. While working out some examples for another thread, I ran into this. Confused me for a while and took some time figuring out this behavior.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Mon Nov 17, 2003 12:45 pm   
 
This is actually a minor bug in the parser.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Nov 17, 2003 7:18 pm   
 
Good idea. There should also be clarification that spaces are required on either side of not, and, or, and xor. Otherwise, someone might try to use
#IF (not1and1or1xor1) {#SHOW match} {#SHOW nomatch}
when they really meant
#IF (not 1 and 1 or 1 xor 1) {#SHOW match} {#SHOW nomatch}

Spaces are important to zMUD. There is an example of the correct use of each operator immediately preceding its definition and in two cases, ! and the first -, no spaces are indicated. In all other cases, spaces are indicated. It is easily inferred that correct usage is to omit spaces with the two operators which don't have them in the example and to use spaces with all other operators.

This is not a bug. The spaces are how zMUD determines whether the | should be interpreted as a separate operator or as part of a string or stringlist.
Reply with quote
Cuttlefish
Apprentice


Joined: 28 Oct 2003
Posts: 164

PostPosted: Mon Nov 17, 2003 7:57 pm   
 
Right. I thought the and/or/etc ones were less of a problem since I would never try to run those together. However, it doesn't hurt to point it out. This threw me because | and & do not require spaces in most other languages that use them.

The thing is, spaces aren't ALWAYS needed around the |. For example, if you have a function call on either side it parses it as you would expect, even without spaces. The rule is probably that literals need to have spaces between them and the |.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Mon Nov 17, 2003 11:29 pm   
 
I believe the rule is non-alpha character. Which is why I said 0|0 not working as expected could be considered a minor bug. Lighbulb is quite correct as well, spaces are very important.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net