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

2008-08-21 Thread Peter Scott
On Tue, 19 Aug 2008 23:59:50 +0200, Aristotle Pagaltzis wrote:
 That said, I really *really* like the idea of embedded dashes
 in identifiers (not least because underscores offend my amateur
 typophile self), but the idea of being able to embed other
 operator-ish symbols in identifiers leaves me utterly cold. I
 strongly doubt that if they are put in, it'll cause the end of
 Perl 6, as you argue, but I also don't care at all about whether
 they are allowed. I'm not going to use them anyway.

Well that'll make *your* programs easy to read, at least :-)

My point is this: punctuation serves a valuable purpose that shouldn't be
diluted.  It doesn't look like letters and digits (oatmeal) and in Perl,
it means something different too.  That correspondence is very valuable
for reading programs; that when one sees an asterisk, it means
multiplication or splat or a few other possibilities, but it isn't part of
an identifier. Identifiers form a large proportion (most?) of a program's
text, and being able to tell *quickly* where they begin and end is crucial
to reading code.  Having to keep at the back of one's mind the possibility
that some symbols with other meanings are also overloaded with
identifier-ness seems to me such a large loss as to outweigh the gain from
permissiveness.  Even if a program doesn't exercise that permission, the
possibility that it *might* introduces extra caution in reading code. 
Even if subconsciously, even if measured in milliseconds, I contend that
is important.

Just because some other languages do it doesn't mean Perl should, unless
you know of some studies showing that readability hasn't been impaired. 
I'm willing to be surprised.

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/



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

2008-08-20 Thread Larry Wall
On Tue, Aug 19, 2008 at 11:59:50PM +0200, Aristotle Pagaltzis wrote:
: * Peter Scott [EMAIL PROTECTED] [2008-08-13 19:20]:
:  If we allow operator symbols in identifiers then the world
:  will divide into those people who look at Perl 6 programs
:  only through syntax-highlighting editors and don't know what
:  all the fuss is about naming a variable $e*trade since it is
:  all purple, and those people who give up on reading the other
:  people's programs.
: 
: False dilemma. See Bob Rogers’ mail in this thread; some
: languages already allow all these symbols and the net effect
: is zero, because they take more work to type and people are
: lazy.
: 
: That said, I really *really* like the idea of embedded dashes
: in identifiers (not least because underscores offend my amateur
: typophile self), but the idea of being able to embed other
: operator-ish symbols in identifiers leaves me utterly cold. I
: strongly doubt that if they are put in, it’ll cause the end of
: Perl 6, as you argue, but I also don’t care at all about whether
: they are allowed. I’m not going to use them anyway.

If one wants them, all you need to do is override the apostrophe rule
in the standard grammar, so I'm not going to go out of my way to add
maximum flexibility to the base grammar.  Currently the apostrophe
rule reads:

token apostrophe {
[ ' \- ]
}

Larry


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

2008-08-19 Thread Aristotle Pagaltzis
* Peter Scott [EMAIL PROTECTED] [2008-08-13 19:20]:
 If we allow operator symbols in identifiers then the world
 will divide into those people who look at Perl 6 programs
 only through syntax-highlighting editors and don't know what
 all the fuss is about naming a variable $e*trade since it is
 all purple, and those people who give up on reading the other
 people's programs.

False dilemma. See Bob Rogers’ mail in this thread; some
languages already allow all these symbols and the net effect
is zero, because they take more work to type and people are
lazy.

That said, I really *really* like the idea of embedded dashes
in identifiers (not least because underscores offend my amateur
typophile self), but the idea of being able to embed other
operator-ish symbols in identifiers leaves me utterly cold. I
strongly doubt that if they are put in, it’ll cause the end of
Perl 6, as you argue, but I also don’t care at all about whether
they are allowed. I’m not going to use them anyway.

Regards,
-- 
Aristotle Pagaltzis // http://plasmasturm.org/


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

2008-08-13 Thread Larry Wall
On Mon, Aug 11, 2008 at 11:34:03AM -0600, Tom Christiansen wrote:
: 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

The thing that convinced me this was a good idea is that it corresponds
pretty closely to what English orthography uses.

The thing that convinced me it's not a bad idea is that it is almost
certain that the compiler will catch any mistakes because it's strict.

In that context, the question of how often people will make such
mistakes is a secondary consideration.  I was reassured on the
apostrophe score that the entire test suite only made the new
mistake twice.  I'll have a better idea about the frequency of
hyphen mistakes once STD implements symbol tables and complains
about undefined subs, which will catch flubs like time-time or
time-do.

On the subject of 0-ary functions, there's no entire solution, but one
of the things we are doing is getting rid of all the 0-or-1-ary
functions which only add to the confusion.  For instance, rand
is now 0-ary only, and to get something other than a number in
the range 0..^1 you must use something like:

rand*100
100.rand
(1..100).pick

And, in fact, if you say rand 100 the current STD grammar complains:

Obsolete use of rand(N); in Perl 6 please use N.rand or (1..N).pick instead

Larry


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

2008-08-13 Thread Peter Scott
On Tue, 12 Aug 2008 10:03:03 +0200, Michael Mangelsdorf wrote:
 I also tried to say that as special characters (not 7-bit ASCII)
 like for hyper ops have already been admitted, the question of just how
 far ($foobar) this admission should (be allowed to) is just around
 the corner.

Completely my 2¢ following.

Even if programmers want to be able to put funny characters in variable
names, I'm against allowing them to embed characters that already have
other meaning in the language (grandfathered exception: underscore).  I
expect +, *, / to be operators with some kind of additive, multiplicative,
and divisive semantics, and I am going to have a very hard time reading
programs that contain variables like $foo*bar without a mental derailing
at that asterisk.  I won't mind $ricks_café, or $coke® or $¢ =
$dollars*100 because those symbols have no other meaning in the language,
but if we allow operator symbols in identifiers then the world will divide
into those people who look at Perl 6 programs only through
syntax-highlighting editors and don't know what all the fuss is about
naming a variable $e*trade since it is all purple, and those people
who give up on reading the other people's programs.

I'm all for giving people enough rope to either hang themselves or make a
hammock, but do we really want to open this can of worms?

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/



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

2008-08-12 Thread Michael Mangelsdorf
 
Dear Thomas,

Is this supposed to be a joke
Absolutely not. What I was trying to say is that there seems
to be a trend to consider very relaxed identifier rules a good thing.

If Perl 6 wants to grab the road for 20 years, then perhaps
this issue is more serious (this is why I quoted you in particular)
than is obvious, because just as has been pointed out,
relaxed identifiers could become what programmers actually expect.

I also tried to say that as special characters (not 7-bit ASCII)
like for hyper ops have already been admitted, the question of just how
far ($foobar) this admission should (be allowed to) is just around
the corner.

When I look at Windows Powershell (dashes everywhere) or XML, where
identifiers literally have to be tagged so we know what they mean,
I can't say it's very pretty.

I'm just interested in where the balance in all this will be.

Apologies, Thom, for being imprecise and seemingly antagonizing.

 
Kindly,
Michael


-Original Message-
From: TSa [mailto:[EMAIL PROTECTED] 
Sent: Dienstag, 12. August 2008 09:25
To: perl6-language@perl.org
Subject: Re: Allowing '-' in identifiers: what's the motivation?

HaloO,

Michael Mangelsdorf wrote:
 Actually I can even imagine allowing almost all chars
 in the middle of identifiers.
 
 Is this a trend we should extrapolate into the lifetime scope
 of the Perl 6 language?
 How far are we in this process, given Unicode guillemets for hyper ops?

Is this supposed to be a joke or a serious contribution to the
discussion? Mine was serious in the sense that I consider the
enforcement of whitespace for infix ops a good thing or at least
not a bad side-effect. What's so different in $foo-bar versus
$foo*bar, $foo+bar or $foo/bar? The latter might e.g. indicate
path variables. Or imagine a coding convention where junctive
variables bear their generating operator: $foo|bar, $foobar and
$foo^bar.


Regards, TSa.
-- 

The unavoidable price of reliability is simplicity -- C.A.R. Hoare
Simplicity does not precede complexity, but follows it. -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan



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

2008-08-12 Thread Nicholas Clark
On Mon, Aug 11, 2008 at 09:07:33AM -0400, Mark J. Reed wrote:
 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.

Also, in Perl 6, constants aren't going to be bare words, because unlike
Perl 5, they're not going to be implemented as subroutines. So that's
another obvious thing that actually isn't going to matter here.

Nicholas Clark


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

2008-08-12 Thread John M. Dlugosz

Nicholas Clark nick-at-ccl4.org |Perl 6| wrote:


Also, in Perl 6, constants aren't going to be bare words, because unlike
Perl 5, they're not going to be implemented as subroutines. So that's
another obvious thing that actually isn't going to matter here.


A Cconstant in Perl 6 can be declared with or without a sigil.  Whether they 
are implemented as subroutines or not doesn't change how they look in the code: 
they can indeed be bare words.


--John


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

2008-08-12 Thread Mark J. Reed
On Tue, Aug 12, 2008 at 4:03 AM, Michael Mangelsdorf [EMAIL PROTECTED] wrote:
 relaxed identifiers could become what programmers actually expect.

Relaxing the rules is fine, but I would like to state for the record
that I'd rather not ever see whitespace allowed in identifiers.
That's an Applescript feature that I could do without in Perl. (Not
that anyone was proposing such a thing, just getting my objection out
there preemptively. :))

-- 
Mark J. Reed [EMAIL PROTECTED]


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

2008-08-12 Thread Darren Duncan

Mark J. Reed wrote:

On Tue, Aug 12, 2008 at 4:03 AM, Michael Mangelsdorf [EMAIL PROTECTED] wrote:

relaxed identifiers could become what programmers actually expect.


Relaxing the rules is fine, but I would like to state for the record
that I'd rather not ever see whitespace allowed in identifiers.
That's an Applescript feature that I could do without in Perl. (Not
that anyone was proposing such a thing, just getting my objection out
there preemptively. :))


Considering that AFAIK we can use absolutely any character string at all as 
an identifier as long as it is string-quoted, that feature should be enough 
to let us use things like whitespace in names, so unquoted identifier names 
should err on the side of being more strict and limited, I think. -- Darren 
Duncan


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

2008-08-12 Thread Austin Hastings
Actually, I proposed some years ago allowing separable verbs -- 
function/method/operator names with spaces in them, that could in fact 
bracket or intersperse themselves with other parameters.


This would be a way of writing if ... elsif ... else ... for example.

I wonder if whitespace in identifiers should be significant? Should $foo 
bar be the same as $foo  bar (2 spaces) ?


=Austin

Mark J. Reed wrote:

On Tue, Aug 12, 2008 at 4:03 AM, Michael Mangelsdorf [EMAIL PROTECTED] wrote:
  

relaxed identifiers could become what programmers actually expect.



Relaxing the rules is fine, but I would like to state for the record
that I'd rather not ever see whitespace allowed in identifiers.
That's an Applescript feature that I could do without in Perl. (Not
that anyone was proposing such a thing, just getting my objection out
there preemptively. :))

  




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

2008-08-12 Thread Brandon S. Allbery KF8NH


On 2008 Aug 12, at 20:39, Austin Hastings wrote:

Actually, I proposed some years ago allowing separable verbs --  
function/method/operator names with spaces in them, that could in  
fact bracket or intersperse themselves with other parameters.


This would be a way of writing if ... elsif ... else ... for  
example.


If you can define circumfix operators, and an operator can be a word  
token, then we already have this, I'd think.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH




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

2008-08-12 Thread Bob Rogers
   From: TSa [EMAIL PROTECTED]
   Date: Tue, 12 Aug 2008 09:25:27 +0200

   . . .

   What's so different in $foo-bar versus $foo*bar, $foo+bar or
   $foo/bar? The latter might e.g. indicate path variables.

FWIW, one sees hyphen substitution like this only very rarely in
Common Lisp code, despite the fact that programmers have unbelievable
freedom to use arbitrary characters in identifiers, even parens (with
quoting).  There are a few visual conventions that use characters you
won't see in Java, such as *foo* for a global, +foo+ for a global
constant, %foo or .foo. for something internal, etc.  But if the
name is long enough to require several words, people almost invariably
use - internally, because out of all this variety (surprise) it's
still easiest to type.

   So IMHO it would be a shame to support the extra complexity in order
to provide a freedom that is used so rarely that it mostly just trips
people up.  (That's an argument against $foo*bar et. al., but I admit
it tends to support $foo-bar.  Unless we all switch to Emacs.  ;-)

   Or imagine a coding convention where junctive variables bear their
   generating operator: $foo|bar, $foobar and $foo^bar.

That gives these variables names that add no information, which sounds
like a bad idea.  I have sometimes seen similar code, e.g.

(defun solve-quadratic (a b c)
  (let ((sqrt[b^2-4*a*c] (sqrt (- (* b b) (* 4 a c
(2*a (* 2 a)))
(values (/ (+ (- b) sqrt[b^2-4*a*c]) 2*a)
(/ (- (- b) sqrt[b^2-4*a*c]) 2*a

Every token that is not ( or ) or whitespace is a valid CL
identifier.  But in this case, sqrt[b^2-4*a*c] is better called
sqrt-discriminant anyway.

-- Bob


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

2008-08-11 Thread Aristotle Pagaltzis
* John M. Dlugosz [EMAIL PROTECTED] [2008-08-11 06:25]:
 I do agree that it may be better for multi-word identifiers
 than camel case or underscores, as seen in many other languages
 that the great unwashed masses have never heard of.

XML and the stack of related technologies also do this (in
particular, variables and functions in XPath), which is where
I first encountered identifiers with dashes. I have been wishing
I could have them in mainstream languages ever since.

Regards,
-- 
Aristotle Pagaltzis // http://plasmasturm.org/


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

2008-08-11 Thread Mark J. Reed
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.

And multi-word-expressions without hitting the shift key!  My RSI thanks you.

-- 
Mark J. Reed [EMAIL PROTECTED]


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

2008-08-11 Thread Bob Rogers
   From: Mark J. Reed [EMAIL PROTECTED]
   Date: Mon, 11 Aug 2008 09:07:33 -0400

   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 . . .

Amen.  I've long since reprogrammed - to give _ if pressed once and
- if pressed twice, when editing languages with C-like identifiers.
So from my perspective, the added visual complexity is not worth it.

-- Bob Rogers
   http://rgrjr.dyndns.org/


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

2008-08-11 Thread Austin Hastings
That sounds cool. Did you do it at the editor level, or at the keyboard 
level?


=Austin

Bob Rogers wrote:

   From: Mark J. Reed [EMAIL PROTECTED]
   Date: Mon, 11 Aug 2008 09:07:33 -0400

   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 . . .

Amen.  I've long since reprogrammed - to give _ if pressed once and
- if pressed twice, when editing languages with C-like identifiers.
So from my perspective, the added visual complexity is not worth it.

-- Bob Rogers
   http://rgrjr.dyndns.org/

  




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

2008-08-11 Thread Tom Christiansen
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


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

2008-08-11 Thread Michael Mangelsdorf

Actually I can even imagine allowing almost all chars
in the middle of identifiers.

Is this a trend we should extrapolate into the lifetime scope
of the Perl 6 language?
How far are we in this process, given Unicode guillemets for hyper ops?

 
Kindly,
Michael

-Original Message-
From: TSa (Thomas Sandlaß) [mailto:[EMAIL PROTECTED] 
Sent: Montag, 11. August 2008 19:55
To: perl6-language@perl.org
Subject: Re: Allowing '-' in identifiers: what's the motivation?

On Monday, 11. August 2008 05:35:03 John M. Dlugosz wrote:
 E.g. see http://www.perlmonks.org/?node_id=703265 :

 sub bar {
  return 100;
 }
 sub foo { 50;}
 sub foo-bar {
return  rand(50);
}
 if (foo - bar != foo-bar) {
print Haha!\n;
 }

Actually I can even imagine allowing almost all chars
in the middle of identifiers. The price is that *all*
infix operators need spaces. This seems to be the trend
right now. See e.g. the disambiguation of meta reduce
and array constructors or adverbs versus nouns in the
call syntax.

So, how simple would a tokenizer become when whitespace
separates almost all tokens? Noteable exceptions would be
the pre- and postfix operators.


Regards, TSa.
-- 
The unavoidable price of reliability is simplicity -- C.A.R. Hoare
Simplicity does not precede complexity, but follows it. -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan



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

2008-08-11 Thread Bob Rogers
   From: Austin Hastings [EMAIL PROTECTED]
   Date: Mon, 11 Aug 2008 10:02:06 -0500

   That sounds cool. Did you do it at the editor level, or at the keyboard 
   level?

   =Austin

In Emacs; see rgr-c-electric-dash-mode in [1], or other similar
solutions in [2].  That way, I can turn it on for C and Perl (among
others), and off for Lisp and text.

   Of course, that's just the tip of the iceberg, but this is OT, so
I'll keep the Emacs evangelism off-list.  ;-}

-- Bob

[1]  https://rgrjr.dyndns.org/svn/rgr-hacks/trunk/rgr-c-hacks.el

[2]  E.g. http://www.emacswiki.org/cgi-bin/wiki/ElectricDotAndDash,
 http://svn.clouder.jp/repos/public/yaml-mode/trunk/yaml-mode.el


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

2008-08-11 Thread Darren Duncan

Mark J. Reed wrote:

On Mon, Aug 11, 2008 at 1:34 PM, Tom Christiansen [EMAIL PROTECTED] wrote:

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


I believe the word you're looking for is 'nullary.


Alternately, the word is spelled niladic, which also has the advantage of 
looking like monadic, dyadic, etc. -- Darren Duncan


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

2008-08-11 Thread Aristotle Pagaltzis
* Michael Mangelsdorf [EMAIL PROTECTED] [2008-08-11 20:25]:
 Unicode guillemets for hyper ops?

Unicode? I don’t know about your ISO-8859-1, but mine has
guillemets. :-)

Regards,
-- 
Aristotle Pagaltzis // http://plasmasturm.org/


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

2008-08-10 Thread John M. Dlugosz

E.g. see http://www.perlmonks.org/?node_id=703265 :

sub bar {
return 100;
}
sub foo { 50;}
sub foo-bar {
  return  rand(50);
  }
if (foo - bar != foo-bar) {
  print Haha!\n;
}


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

2008-08-10 Thread Austin Hastings
At a minimum, there are more multi-word identifiers than there are 
statements involving subtraction. Further, '-' is basic, while all of 
[_A-Z] are not.


Ergo, a multi-word-identifier is easier to type than a 
multi_word_identifier or a multiWordIdentifier.


The older I get, the more I like Cobol, and now *ML, for getting this 
stuff right.


=Austin

John M. Dlugosz wrote:

E.g. see http://www.perlmonks.org/?node_id=703265 :

sub bar {
return 100;
}
sub foo { 50;}
sub foo-bar {
  return  rand(50);
  }
if (foo - bar != foo-bar) {
  print Haha!\n;
}





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

2008-08-10 Thread John M. Dlugosz

Austin Hastings Austin_Hastings-at-Yahoo.com |Perl 6| wrote:
At a minimum, there are more multi-word identifiers than there are 
statements involving subtraction. Further, '-' is basic, while all of 
[_A-Z] are not.


Ergo, a multi-word-identifier is easier to type than a 
multi_word_identifier or a multiWordIdentifier.


The older I get, the more I like Cobol, and now *ML, for getting this 
stuff right.


I do agree that it may be better for multi-word identifiers than camel 
case or underscores, as seen in many other languages that the great 
unwashed masses have never heard of.  I tried it in my writings the same 
day.


--John