Re: String concatenation design




Anton Treuenfels wrote:
I have a numeric expression parser that allows literal strings to be used in
logical expressions (such as comparisons) because the results of those are
numeric. I gave the relevant string operators a very high precedence because
that seemed the easiest way to prevent numeric operators from engaging
string operands.

So the expression

"ABC" < "DEF" + 1

is parsed as

("ABC" < "DEF") + 1

and yields the value 2.

why does boolean + numeric -> numeric.

boolean + numeric could go to boolean or be disallowed IMO.
Or is the current semantic particularly useful and if so where?

regards
Andy Little

.



Relevant Pages

  • Re: Coding Horrors, Cargo Cult Programming, and other Ghoulish Things
    ... a boolean, so why should I add a relation to get another boolean [my ... Where C syntax requires parentheses around logical expressions, Pascal syntax doesn't allow for anything but a logical expression for a condition. ... If this difference is not hardwired in the head of an coder, he should stick to a single language, IMO. ...
    (borland.public.delphi.non-technical)
  • Re: Complex if statement.
    ... No, in C#, logical expressions short circuit themselves if it can ... Not sure where you get that idea about Java from: ... boolean b = false; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Complex if statement.
    ... No, in C#, logical expressions short circuit themselves if it can not ... boolean b = false; ...
    (microsoft.public.dotnet.languages.csharp)