in reply to Re: Why not support this syntax?
in thread Why not support this syntax?

Penultimately, I say it's definitely not complicated enough. When I can talk to it in English and have it do what I want, then it'll be complicated enough.

Well OK then, how does the proposal generalize to things like this:

$mystery = $a < $b < $c < $d < $f;

Quick - say: which one is the ternary operator? Why cause such problems when a little subroutine is enough?

In a less tongue-in-cheek mode, the complexity of the parser shouldn't, IMHO, drive the development of the language. The first sentence of the Preface of the Camel book is 'Perl is a language for getting your job done'. It's not 'Perl is a language with a reasonably, but not unreasonably, complicated parser'.

Perl is a language for getting your job done - right. After writing this little subroutine, the job is done. Why wait for other people to do jobs for you that you can do for yourself in 30 seconds.

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com

Replies are listed 'Best First'.
Re^3: Why not support this syntax?
by tadman (Prior) on Apr 24, 2001 at 19:05 UTC
    I could only guess that it would be:     $mystery = ($a < $b) && ($b < $c) && ($c < $d) && ($d < $f); As in, for any:     A x B y C Where 'x' and 'y' are one of ('>','>=','<','<='), then the equivalent would be:     (A x B) && (B y C) Which would also hold true for:
    A < B >= C -> (A < B) && (B >= C) A > B < C -> (A > B) && (B < C)
    And so forth.

      Good idea, and we can even cover that one ourselves, too:

      sub is_ordered_according_to { my ($binary_predicate, @values) = @_; if (@values < 3) { return $binary_predicate->(@values); } else { return $binary_predicate->($values[0], $values[1]) && is_ordered_according_to($binary_predicate, @values[1..$#values]); } } sub less_than { return shift() < shift(); } print is_ordered_according_to(\&less_than, 1, 2, 3, 4, 5, 6) ? "yes" : "no", "\n" ; print is_ordered_according_to(\&less_than, 3, 2, 1, 4, 5, 6) ? "yes" : "no", "\n" ; print is_ordered_according_to(\&less_than, 1, 2, 3, 4, 6, 5) ? "yes" : "no", "\n" ;

      Christian Lemburg
      Brainbench MVP for Perl
      http://www.brainbench.com

        Nice, but try this:
        $val = $min <= $x < $y <= $z <= $max
        IMO, A syntactic solution would be both cleaner and faster.
           MeowChow                                   
                       s aamecha.s a..a\u$&owag.print

        Cool. If you don't mind, I'll just add this to my personal collection of bits o'code.

        Good idea, and we can even cover that one ourselves, too

        But we can cover *anything* ourselves ... with enough effort.

        From another of your posts on the same topic:

        Perl is a language for getting your job done - right. After writing this little subroutine, the job is done. Why wait for other people to do jobs for you that you can do for yourself in 30 seconds.

        I don't think anyone said anything about *waiting*.

        Making Perl6 will require a great deal of effort, it's going to happen regardless of whether or not this particular syntax is included, and the process of deciding what the syntax will be has been deliberately opened to public debate.

        So why not let everyone know on what we think said effort should be spent constructing?

        Philosophically yours,

        Scott