perl6-language
[Top] [All Lists]

Re: Allowing '-' in identifiers: what's the motivation?

To: "Mark J. Reed" <markjreed@gmail.com>
Subject: Re: Allowing '-' in identifiers: what's the motivation?
From: Tom Christiansen <tchrist@perl.com>
Date: Mon, 11 Aug 2008 11:34:03 -0600
Cc: perl6-language@perl.org
Delivered-to: mailing list perl6-all@perl.org
Delivered-to: perl6-all-poster@perl.org
Delivered-to: mailing list perl6-language@perl.org
Delivered-to: perl6-language@perl.org
In-reply-to: Message from "Mark J. Reed" <markjreed@gmail.com> of "Mon, 11 Aug 2008 09:07:33 EDT." <f60fe000808110607y3c8b85efj152b3a4f81a3c80d@mail.gmail.com>
List-help: <mailto:perl6-all-help@perl.org>
List-id: <perl6-all.perl.org>
List-id: <perl6-language.perl.org>
List-post: <mailto:perl6-all@perl.org>
List-subscribe: <mailto:perl6-all-subscribe@perl.org>
List-unsubscribe: <mailto:perl6-all-unsubscribe@perl.org>
Mailing-list: contact perl6-all-help@perl.org; run by ezmlm
>I'm still somewhat ambivalent about this, myself.  My previous
>experience with hyphens in identifiers is chiefly in languages that
>don't generally have algebraic expressions, e.g. LISP, XML, so it will
>take some getting used to in Perl.  But at least in Perl's case the
>subtraction conflict is mitigated by the fact that many subtraction
>expressions will involve sigils;  $x-$y can't possibly be a single
>identifier.

People use nonadic functions (nonary operators? where non = 0, not 9)
without parens, and get themselves into trouble for it.

    % perl -E 'say time-time'
    0

    % perl -E 'say time-do{sleep 3; time}'
    -3

    % perl -E 'say time +5'
    1218475824

    % perl -E 'say time -5'
    1218475817

    % perl -E 'say time(-5)'
    syntax error at -e line 1, near "(-"
    Execution of -e aborted due to compilation errors.
    Exit 19

--tom


<Prev in Thread] Current Thread [Next in Thread>