Worst ideas/features in programming languages?
Basile B.
b2.temp at gmx.com
Wed Oct 27 01:18:47 UTC 2021
On Monday, 25 October 2021 at 12:00:09 UTC, ClapTrap wrote:
> Pascal has shr, shl, begin, end, maybe other wordy stuff, where
> do you draw the line? Or rather where do you write "line"? :)
The line is simply the style consistency.
- `and` and `or` are named operators
- `&&` and `||` are symbolic operators
Named operators cause problems for the sustainability of a
language over time. A language should be consistent, so when new
operators have to be added, pascal-like languages must stick to
the tradition.
A few years back there was a discussion on the freepascal forums
about [the conditional
expressions](https://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg41242.html). To keep the language coherant (i.e dont start to use _symbolic operators_) the final proposition was an intrinsic `IfThen`.
It's easier to create new operators if the _symbolic_ style is
used.
To go back to `&&` and `||`...
There are just the shortcut versions of `&` and `|` ...
Pascal can use `and` and `or` for both logical and bitwise
arithmetic expressions for the sole and unique reason that
**there is no implicit conversion** from `Boolean` to the integer
types and and no implicit boolean evalation of integer types.
So... in `if e1 and e2 then ...`, to compile `and` has to be a
shortcut logical and. dot. (`e3 := e1 and e2; if e3 then...` is
not rewritten `if e3 <> 0 then...`.)
You see that finally this has nothing to do with the hype or
whatever. In both case the style and the semantic are perfectly
coherant.
More information about the Digitalmars-d
mailing list