Implies operator

Mariano rotoshi at yahoo.com
Tue Nov 14 05:04:20 PST 2006


Wouldn't it be nice to have an ''implies'' operator?

  if(A -> B)

I know this can be written as

  if(!A || B)

but the implication makes it far more clear for common day speach

  if( check_boundaries -> a.length <= max_int )
      process(a);

makes more sence than

  if( !check_boundaries || a.length <= max_int )
      process(a);

or

  if( ! (check_boundaries && a.length > max_int ) )
      process(a);

besides, I don't think the '->' notation should be a big problem for
the parser, and the front end can easily convert this structure to
the corresponding not + or/and.

There is, of course, still the issue of precedence, but I think it
should match that of || and &&.

And since Walter likes Wikipedia links: http://en.wikipedia.org/wiki/
Logical_implication

Mariano



More information about the Digitalmars-d mailing list