Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Aug 2001 15:46:30 -0700
From:      "brian o'shea" <boshea@netapp.com>
To:        Raymond Wiker <Raymond.Wiker@fast.no>
Cc:        les@safety.net, Rob <europax@home.com>, "hackers@FreeBSD.ORG" <hackers@FreeBSD.ORG>
Subject:   Re: the =+ operator
Message-ID:  <20010810154630.A27553@netapp.com>
In-Reply-To: <15220.9386.441669.962830@raw.grenland.fast.no>; from Raymond Wiker on Fri, Aug 10, 2001 at 08:15:06PM %2B0200
References:  <3B73F0BC.548D40B3@home.com> <200108101446.HAA99867@safety.net> <15220.9386.441669.962830@raw.grenland.fast.no>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Aug 10, 2001 at 08:15:06PM +0200, Raymond Wiker wrote:
> 
> 	This is actually wrong - the += and -= operators were
> originally written as =+ and =-. This is obviously ambiguous, given
> the fact that whitespace is ignored.

Why does this have to be ambiguous?  Consider this:

    int      o = 2;
    int     *p = &o;
    int      q = 8;
    int      r;

    r = q/*p  /* comment */;

    printf("r == %d\n", r);


Is this equivalent to the following:

    r = q / *p;


Or is it equivalent to this:

    r = q              /* p  /* comment */ ;


C disambiguates between these two possible interpretations by matching
the largest possible token.  Thus, it is taken to be equivalent to:

    r = q;


In other words, these two lines are not equivalent:

    r = q/*p  /* comment */;

    r = q/ *p  /* comment */;


So, the =+ operator could be interprited correctly as long as it is the
largest possible token.  It does leave more of an opportunity for human
misinterpritation, while my example is less likely to be seen.

-brian

-- 
Brian O'Shea     "Stare not too deeply into the pen,   <boshea@netapp.com>
3.3.163(PEN)      lest the pen stare back into you."        (408) 822-3249
--------------------------------------------------------------------------

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010810154630.A27553>