Perl loops should use break, not last

Discussion in 'Perl' started by Jeremy Morton, Jan 29, 2005.

  1. Probably been mentioned before but I fail to see why Perl changed the
    'break' keyword to 'last', in loops. Bear with me on this - it seems
    semantically more accurate to say 'break' - you're immediately breaking out
    of the loop. 'last' makes it sound like the current loop will be the last,
    but not that the execution should be stopped immediately, whereas break
    makes it sound like the latter.

    Where can I propose that this be changed, or break aliased to last, for Perl
    6?


    --
    Best regards,
    Jeremy Morton (Jez)
    Jeremy Morton, Jan 29, 2005
    #1
    1. Advertising

  2. Jeremy Morton

    Big and Blue Guest

    Jeremy Morton wrote:
    > Bear with me on this - it seems
    > semantically more accurate to say 'break' - you're immediately breaking out
    > of the loop. 'last' makes it sound like the current loop will be the last,


    The semantics of 'break' or 'last' are defined by the language (in this
    case Perl), not by you.

    Why not think of 'last' as "this is the last statement to run for the
    loop".

    It's always struck me as odd that the 'continue' statement in 'C'
    starts the next pass of a loop. This is definitely a strange use of the
    concept of "continue". But it is the semantics of 'C', so I accept it.
    By trying to map particular programming concepts into single English words
    with exisiting meaning there is always going to be some sort of mismatching
    oddity.


    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue, Jan 30, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. viza

    break or continue out of nested loops

    viza, Jul 16, 2003, in forum: C Programming
    Replies:
    5
    Views:
    1,004
    sunil
    Jul 17, 2003
  2. Replies:
    12
    Views:
    935
  3. Talha Oktay
    Replies:
    3
    Views:
    163
    Simon Kröger
    Mar 30, 2006
  4. Jeremy Morton

    Perl loops should use break, not last

    Jeremy Morton, Jan 29, 2005, in forum: Perl Misc
    Replies:
    34
    Views:
    389
    Charlton Wilbur
    Jan 31, 2005
  5. Me
    Replies:
    2
    Views:
    229
Loading...

Share This Page