The Canadian Guitar Forum banner

Which is the one true increment?

  • "+1" - obviously

    Votes: 2 40.0%
  • "++" - anything else is blasphemous

    Votes: 0 0.0%
  • 42

    Votes: 1 20.0%
  • Someone told me that Yngwie was in here

    Votes: 2 40.0%

  • Total voters
    5
1 - 13 of 13 Posts

·
Registered
Joined
·
40 Posts
Discussion Starter #1
Though I've been a guitarist for a relatively large number of years, only recently have I involved myself in a few of the many guitar communities found on the web.

Conversely, having become somewhat of a programmer in comparatively less years, I've spent countless hours participating in so-called "geek" communities on the web.

The similarities between the two types of communities are many. A few that spring to mind:
  • a general and oftentimes overwhelming enthusiasm for the topic
  • a healthy mixture of professionals, hobbyists, tweakers, and n00bs
  • a large male:female disparity
Of course, as with all communities, there are some differences. Most of them are minor but there is one that concerns me; nomenclature. Specifically the incorrect use of "+1" as an increment operator.

The purpose of this post is to illustrate, in a totally petty, pedantic, and wholly tongue-in-cheek manner, that the use of "+1" is incorrect and that the correct nomenclature is in fact "++" as used in most "geek" communities.

To whit:

<?php
$foo = 'A sentence within which an opinion I share is contained.';

$bar = $foo + 1;
echo "foo plus one: " . $bar . "\n";

$baz = $foo++;
echo "foo plus plus: " . $baz . "\n";
?>
// Results
foo plus one: 1
foo plus plus: A sentence within which an opinion I share is contained.
Though you may be unfamiliar with the code, the results speak for themselves. Adding 1 to "A sentence within which an opinion I share is contained" results in 1. Whereas incrementing "A sentence within which an opinion I share is contained." with the ++ operator results in "A sentence within which an opinion I share is contained."

Accordingly, if your intention when adding 1 to a previously stated opinion or fact is to replace the opinion or fact with an integer then your use of "+1" is correct. However, if your intention is to indicate your agreement or affinity with a previously stated opinion or fact, or you desire to add weight to the opinon or fact by echoing it, then "++" is the clearly correct choice.
 

·
Registered
Joined
·
1,155 Posts
Schluppy said:
Though I've been a guitarist for a relatively large number of years, only recently have I involved myself in a few of the many guitar communities found on the web.

Conversely, having become somewhat of a programmer in comparatively less years, I've spent countless hours participating in so-called "geek" communities on the web.

The similarities between the two types of communities are many. A few that spring to mind:
  • a general and oftentimes overwhelming enthusiasm for the topic
  • a healthy mixture of professionals, hobbyists, tweakers, and n00bs
  • a large male:female disparity
Of course, as with all communities, there are some differences. Most of them are minor but there is one that concerns me; nomenclature. Specifically the incorrect use of "+1" as an increment operator.

The purpose of this post is to illustrate, in a totally petty, pedantic, and wholly tongue-in-cheek manner, that the use of "+1" is incorrect and that the correct nomenclature is in fact "++" as used in most "geek" communities.

To whit:



Though you may be unfamiliar with the code, the results speak for themselves. Adding 1 to "A sentence within which an opinion I share is contained" results in 1. Whereas incrementing "A sentence within which an opinion I share is contained." with the ++ operator results in "A sentence within which an opinion I share is contained."

Accordingly, if your intention when adding 1 to a previously stated opinion or fact is to replace the opinion or fact with an integer then your use of "+1" is correct. However, if your intention is to indicate your agreement or affinity with a previously stated opinion or fact, or you desire to add weight to the opinon or fact by echoing it, then "++" is the clearly correct choice.
+1 :banana: :banana: :banana: :banana:
 
I

·
Guest
Joined
·
0 Posts
Let me start with: Down this path madness lies. :tongue:

I'd argue that "+1" is intended to work as a pre-increment operator not, as you suggest a post-increment operator. In your example $baz remains a string because the = (assignment) operator takes precedence over the post-increment operator (<var>++). Try echoing $foo at the end and you'll see what I mean: $foo was changed to the value 1 by your $foo++ operation.

If you switch to pre-increment you get a counter of the number of times someone supported the idea. For example:


$foo = 'My brilliant idea.';
$baz = ++$foo; // Support the idea once...
echo $baz;
$baz = ++$foo; // Support the idea again...
echo $baz;


Prints 1 and then 2. Which is really more indicative of what's going on in the thread when someone says "+1". It could also be viewed as a slightly munged version of the increment-and-assign operator: +=. Same results if we use the += operator like so:


$foo = 'My brilliant idea.';
$foo += 1; // Support the idea once...
echo $foo;
$foo += 1; // Support the idea again...
echo $foo;


And now the syntax is much similar.

Although in both cases I'm trouble by the fact that the original idea held by $foo is lost in the counting effort. Might I suggest we all switch from "+1" to something that allows $foo to persist? How about using reverse polish notation? If you suggest and idea push it on the stack. Supporters and detractors just add and subtract from it from there:


"My brilliant idea" <enter>
1 <enter> + <enter> // I support the idea
1 <enter> - <enter> // I do not support the idea
100 <enter> + <enter> // I really support this idea


Now the top value on the stack is always the current support count for $foo and the bottom value on the stack is always the original idea: $foo.

Man I am such a nerd. :wink:
 

·
Registered
Joined
·
40 Posts
Discussion Starter #6
Down this path madness lies.
Tis also where this path began. Drool

I'd argue that "+1" is intended to work as a pre-increment operator not, as you suggest a post-increment operator. In your example $baz remains a string because the = (assignment) operator takes precedence over the post-increment operator (<var>++). Try echoing $foo at the end and you'll see what I mean: $foo was changed to the value 1 by your $foo++ operation.
I'd happily entertain evidence supporting such an argument, however, it should be noted that with either pre or post-increments $foo does not change:

$foo = 'Where are the code tags anways?';
var_dump($foo);
var_dump($foo++);
var_dump(++$foo);

// Results
string(31) "Where are the code tags anways?"
string(31) "Where are the code tags anways?"
string(31) "Where are the code tags anways?"
Granted the possibility of a disimilar configuration causing disparate results, occam's razor (and the php manual) suggest that the non-associative precedence of the increment operator, and perhaps even the different data types, is to blame.

Although in both cases I'm trouble by the fact that the original idea held by $foo is lost in the counting effort. Might I suggest we all switch from "+1" to something that allows $foo to persist?
That $foo persists with the "++" operator is, I believe, is the very reason the "++" meme has flourished elsewhere and should be implemented here.

Imagine, if you will, a forum full of this...
Originally Posted by iaresee
Originally Posted by Schluppy
0
+1
... not very informative. Whereas...

Originally Posted by iaresee
Originally Posted by Schluppy
I really need to practice.
++
... says volumes. In the latter (fictional) example you've expressed to the entire forum that you think I suck horribly - with only two keystrokes! And not only two keystrokes, but two keystrokes on the same key! Not only is "++" expressive but it also saves energy!

How about using reverse polish notation?
-- :tongue:
 
I

·
Guest
Joined
·
0 Posts
Schluppy said:
I'd happily entertain evidence supporting such an argument, however, it should be noted that with either pre or post-increments $foo does not change:
I think this is a typecast issue with PHP -- the value isn't stored because the original value is a string and incrementing a string is not a rational operation. In Perl it does work the way I described (I only have Perl available to test with on my home machine):

my $foo = 'This is a great idea.';
print $foo, "\n";
print $foo++, "\n";
print ++$foo, "\n";
print $foo, "\n";


Gives you:

This is a great idea
This is a great idea
2
2


Granted the possibility of a disimilar configuration causing disparate results, occam's razor (and the php manual) suggest that the non-associative precedence of the increment operator, and perhaps even the different data types, is to blame.
I believe it's the different data types that are to blame.

That $foo persists with the "++" operator is, I believe, is the very reason the "++" meme has flourished elsewhere and should be implemented here.
That seems too quirky to PHP to be the case, don't you think? There just can't be that many PHP developers out there! :)

... says volumes. In the latter (fictional) example you've expressed to the entire forum that you think I suck horribly - with only two keystrokes! And not only two keystrokes, but two keystrokes on the same key! Not only is "++" expressive but it also saves energy!
I dislike any combination that forces me to use the shift key. I say we drop the "+"'s altogether and go with "1".
 

·
Registered
Joined
·
40 Posts
Discussion Starter #11
That seems too quirky to PHP to be the case, don't you think? There just can't be that many PHP developers out there! :)
Oh totally. I'm just being a jackass and chose PHP because it provided the desired result.
 
1 - 13 of 13 Posts
Top