Re: Add a ternary operator to the language?
From: Will DeWitt Jr. (edge_at_boink.net)
Date: 06/23/04
- Next message: Craig Stuntz [TeamB]: "Re: Add a ternary operator to the language?"
- Previous message: Craig Stuntz [TeamB]: "Re: Add a ternary operator to the language?"
- In reply to: Jim Cooper: "Re: Add a ternary operator to the language?"
- Next in thread: Jim Cooper: "Re: Add a ternary operator to the language?"
- Reply: Jim Cooper: "Re: Add a ternary operator to the language?"
- Reply: William Meyer: "Re: Add a ternary operator to the language?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Jun 2004 06:05:47 -0700
Jim Cooper wrote:
>
> > It takes what would traditionally be four lines of code and reduces
> > it to a single line.
>
> But it doesn't improve the readability (ie understanability) of the
> code.
But it doesn't make it any more difficult to understand either. It
*does* improve readability in the sense that now you can see three more
lines at once that you wouldn't have been able to see before. If you
had a lot of code that did this kind of checking (and it's not uncommon
to have such blocks of code) you could save potentially 30+ lines and
make the actual code overall *more* readable.
> A handful of lines here and there makes little difference these days.
> You can save even more lines by writing more than one statement on a
> line :
Yes, but *that* would be confusing to follow. =)
> Less lines is very definitely not equal to clearer code. At best the
> ternary operator is as clear as the alternative, at worst it is a
> hazard to sanity. As I said, I don;t think you've proved your case,
> just proved that you like the construct :-) Since it's one of those
> that there is nowhere near universal agreement about, I think you
> will need a stringer case to get it included in the language.
Well, considering the IfThen functions are a rather recent addition to
the RTL, I'll assume that Borland saw the need at some level and
decided to introduce that hack to (hopefully temporarily) address the
need. Adding a ternary operator proper would be the correct solution,
and I hope Borland can see fit to add this (assuming it's not a time
consuming addition).
Will
-- Want a 64-bit Delphi compiler for AMD64 / IA-32e? Vote here-- http://qc.borland.com/wc/wc.exe/details?reportid=7324
- Next message: Craig Stuntz [TeamB]: "Re: Add a ternary operator to the language?"
- Previous message: Craig Stuntz [TeamB]: "Re: Add a ternary operator to the language?"
- In reply to: Jim Cooper: "Re: Add a ternary operator to the language?"
- Next in thread: Jim Cooper: "Re: Add a ternary operator to the language?"
- Reply: Jim Cooper: "Re: Add a ternary operator to the language?"
- Reply: William Meyer: "Re: Add a ternary operator to the language?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|