Re: Syntax Highlighting Editors Beware
by swampyankee (Parson) on Aug 09, 2008 at 14:18 UTC
|
Can't say I'm a fan of this change. This could permit some slightly confusing code, like:
# any needed definitions, prototypes, etc...
sub bar {
return 100;
}
sub foo { 50;}
sub foo-bar {
return rand(50);
}
if (foo - bar != foo-bar) {
print "Haha!\n";
}
Ah, well, I've not been following Perl 6 developments, so I shouldn't be overly critical, but I can also see this as making it less than straightforward to convert a few Perl 5 scripts which rely on regex including the /\w/ or /\W/ meta-characters to Perl 6.
Information about American English usage here and here. Floating point issues? Please read this before posting. — emc
| [reply] [d/l] |
|
|
| [reply] [d/l] [select] |
|
|
Just out of curiosity (as I've not been following Perl 6) why do some (but not all?) infix operators require spaces? I can understand the need for spaces with operators like eq, where whitespace is needed to separate the operator from the variables surrounding it, but I'm not sure why it would be needed for operators which are not characters permitted in variable names.
Information about American English usage here and here. Floating point issues? Please read this before posting. — emc
| [reply] |
|
|
Re: Syntax Highlighting Editors Beware
by educated_foo (Vicar) on Aug 09, 2008 at 16:11 UTC
|
On the one hand, I'm not worried because Emacs is smart. On the other hand, this is sort of disturbing -- didn't Larry learn from the $Package'thing syntax in Perl 4? | [reply] [d/l] |
|
|
my $x' = f( $x );
my $g'' = f( f( $g ) );
Quite what prompts the resurrection of $this-stuff I can't work out? Wooing the Fortran lobby? The Lisp Libation? It is one shift easier to type than $this_stuff, but that's not saying much.
Now, if we could have variable names $with spaces in them = 1, that would be revolutionary. Funny things is, on the basis of 30 seconds thought, it doesn't seem like it would present that many difficulties to implement.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
|
|
The mathematic notation bit may be sound, except for the bit about "...being followed by a letter."
And being a member of the Cabal of Fortran Programmers, no Fortran programmer would ever consider '-' to be a reasonable character to permit in a variable name. Code like
IF( IF .NE. NE .OR. NE .EQ. OR) THEN(IF, OR, NE)
is bad enough; allowing code like
IF(IF .NE. IF - NE) .OR. IF-NE .NE. NE) THEN(IF, NE, IF-NE)
where IF - NE is an arithmetic operation and IF-NE is a variable would be insufferable.
Information about American English usage here and here. Floating point issues? Please read this before posting. — emc
| [reply] [d/l] [select] |
|
|
my $with = 2;
my $with spaces in them = 4;
print "$with spaces in them\n";
I know in Perl/Gtk2 there is some confusion with signal and property names with - in them, but it's resolved by automatically converting them to underscores.
’key-press-mask’ and ’key_press_mask’
are interpreted as the same thing.I think a space should be a space, and not have any sort of hidden connector usage, what's wrong with underscores? Yeah, that reminds me of tabs and Python.....yuck.
| [reply] [d/l] [select] |
|
|
|
|
|
|
|
That was my thought at first, too, except that the change doesn't allow for that, since ' is terminal rather than followed by another letter. I suggest that ' (but not -) be allowed as terminal too, for this very purpose.l
| [reply] |
Re: Syntax Highlighting Editors Beware
by jettero (Monsignor) on Aug 09, 2008 at 11:05 UTC
|
in vim, I think you'd just add two more characters to the class of characters allowed in an identifier. I don't think it'll cause much trouble... unlike trying to match m[\s*[blarg]\s*] or m^Gblither^G ...
| [reply] [d/l] [select] |
|
|
$one-two vs. $one-$two? or $one-5? I don't have vim, but does it know identifiers only have $ (or @ or %) at the beginning or does it just have $, @ and % in the class of characters allowed in an identifier? And in the last example, digits are in the group, dash was just added ... so it's all one identifier, right?
IMHO, it's a bad idea to allow those two, but that's just me.
| [reply] [d/l] [select] |
|
|
The - has to be followed by another letter, so $one-$two is not affected. Likewise $one-5 since 5 is not a letter.
—John
| [reply] [d/l] [select] |
|
|
|
|
|
|
|
Re: Syntax Highlighting Editors Beware
by dHarry (Abbot) on Aug 10, 2008 at 10:25 UTC
|
The dash (-) has been present in identifiers for a long time.
Two examples:
PowerBuilder will treat the expression A-B as either an identifier or an expression depending on the the value of the DashesInIdentifiers property. If DashesInIdentifiers is set to 1, then A-B is an identifier,if set to 0, then A-B.
In Progress 4GL
Identifiers for any Progress 4GL objects such as a table, field, variable, or internal
procedure, allow the dash characters (but not the first character).
I am sure there are many more languages supporting this. Dashes are also allowed in XML tag names.
The question is if you gain anything from it? I always favoured underscores over dashes for readability. IMHO $this_is_some_name is more readable then $this-is-some-name.
I am not too happy with allowing the quote (‘) in identifiers. I fail to see the benefit. $I'am-afraid-it-will-only-create-confusion;-)
| [reply] |
|
|
I am sure there are many more languages supporting this.
How ironic (?) this should appear in a thread about Syntax Highlighting Editors Beware -- considering what the hallowed standard for emacs-lisp identifiers looks like. Personally, I've been looking forward to this since I first started programming in C (shortly after learning emacs-lisp). It means I need to hit shift only once (for the sigil) when typing a long variable name.
| [reply] |