Re: Overloaded logic operators

m.helvensteijn@gmail.com
Tue, 25 Nov 2008 10:13:50 -0800 (PST)

          From comp.compilers

Related articles
[4 earlier articles]
Re: Overloaded logic operators arnold@skeeve.com (2008-11-25)
Re: Overloaded logic operators mike@mike-austin.com (Mike Austin) (2008-11-25)
Re: Overloaded logic operators mike@mike-austin.com (Mike Austin) (2008-11-25)
Re: Overloaded logic operators mike@mike-austin.com (Mike Austin) (2008-11-25)
Re: Overloaded logic operators lkrupp@pssw.com (Louis Krupp) (2008-11-25)
Re: Overloaded logic operators mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2008-11-25)
Re: Overloaded logic operators m.helvensteijn@gmail.com (2008-11-25)
Re: Overloaded logic operators bc@freeuk.com (Bartc) (2008-11-25)
Re: Overloaded logic operators cdodd@acm.org (Chris Dodd) (2008-11-25)
Re: Overloaded logic operators torbenm@pc-003.diku.dk (2008-11-26)
Re: Overloaded logic operators fswarbrick@gmail.com (Frank Swarbrick) (2008-11-27)
Re: Overloaded logic operators dot@dotat.at (Tony Finch) (2008-12-01)
Re: Overloaded logic operators alexc@TheWorld.com (Alex Colvin) (2008-12-03)
[1 later articles]
| List of all articles for this month |

From: m.helvensteijn@gmail.com
Newsgroups: comp.compilers
Date: Tue, 25 Nov 2008 10:13:50 -0800 (PST)
Organization: Compilers Central
References: 08-11-110 08-11-116
Keywords: design
Posted-Date: 25 Nov 2008 14:50:28 EST

> (Being able to write if a<b<c is neat though and I've just added
> that to my language, with about 5 lines of code; it just converts to
> if (a<b) and (b<c).)


Yes, chained comparison is neat. But watch out. If someone wrote: (a <
b() < c), he would expect b() to only be evaluated once, not twice.
This makes a big difference if b() has side-effects. Also, the syntax
can be extended to mixed comparison operators. For example: (a < b = c
< d).


Did you catch all that in 5 lines of code? Then I admire your code
modularity. :-)


--
Michiel


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.