On Fri, 8 Jun 2001, Chris Hostetter wrote:
> After reading the Apocalypse & Exegesis articles, and seeing some examples
> of properties and the "is" operator, I'd like to suggest that the
> less-then operator be changed, so it is functionally equivalent to:
>
> $v2 = VALUE2;
> $v1 = (defined VALUE1.valueR ? VALUE1.valueR : VALUE1);
> return ($v2-$v1 == abs($v2-$v1)) is valueR($v2);
>
> which (assuming the operator's association was changed to "left") would
> cause the following code to mean what beginning programmers always think it
> should mean:
>
> if ($foo < $bar < $baz) { ... }
>
> It should be obvious how "> <= >= lt gt le ge" can similarly
> be modified. Then even this would make sense...
>
> if ($foo <= $bar > $yak lt $wak) { ... }
For certain definitions of "sense." :>
Seriously, I have several thoughts on this:
1) The "do this because it will be more intuitive for beginners"
argument comes up a lot, and is pretty appealing at first. However, as
someone (was it tchrist?) pointed out, beginners don't stay beginners for
long, so writing a language for beginners may cost you people when they
"grow out of" your language. I don't this we should do this just because
it would be better for beginners; if we're going to do it, let's do it
because it is a good feature.
2) This feature would be very prone to abuse (makes it easier to
obfuscate code), but that isn't a reason to disqualify something either.
3) Used for what it is intended for, it seems like a very concise,
expressive way to do multiple relationship tests without needing all those
"&&"s and such. If we assume that these expressions read from left to
right by overlapped pairs, so that these are equivalent:
($foo < $bar < $baz < $jaz)
(($foo < $bar) && ($bar < $baz) && ($baz < $jaz))
...then I don't think we're giving up any comprehensibility, and
we are gaining conciseness. I vote 'yes' (fwiw).
Dave