On Tue, 29 Sep 1998, Del Minturn wrote:
>I have never seen an if statement do this "if (x = y >= z)". I will bet
>if you change that, you will get some better results.
>If someone knows that this can be done or show me an application that
>does this, I would like to see it or understand what it is actually
>trying to compare. seems like your better off doing x = y && x >= z or
>x = y && y >= z
It's valid. In fact, you'll find this gem in interpreter.c:
if ((num = *temp - '1') < num_of_tokens && num >= 0) {
It could be re-written as:
num = *temp - '1';
if (num < num_of_tokens && num >= 0) {
with the same effect as the first one. It's personal taste most of the
time. Like:
if ((new_buf->data = (char *)calloc(size + 1, sizeof(char))) == NULL)
.vs.
new_buf->data = (char *)calloc(size + 1, sizeof(char));
if (new_buf == NULL)
Other applications:
if (!*buf || !*buf2)
send_to_char("Who do you wish to tell what??\r\n", ch);
else if (!(vict = get_char_vis(ch, buf)))
send_to_char(NOPERSON, ch);
else if (is_tell_ok(ch, vict))
perform_tell(ch, vict, buf2);
So you can do neater nesting.
--
George Greer, greerga@circlemud.org | Genius may have its limitations, but
http://mouse.van.ml.org/ (mostly) | stupidity is not thus handicapped.
http://www.van.ml.org/CircleMUD/ | -- Elbert Hubbard
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST