Welcome to the Monastery PerlMonks

### Re^3: Numification of strings

by LanX (Bishop)
 on Aug 02, 2010 at 12:38 UTC ( #852465=note: print w/replies, xml ) Need Help??

in reply to Re^2: Numification of strings

wow incrementing with ++ is not orthogonal to +1!

```  DB<33> my \$y;\$y++

DB<34> my \$y;\$y+1
Use of uninitialized value \$y in addition (+) at (eval 38)[/usr/share/
+perl/5.10/perl5db.pl:638] line 2.

from perlop

```        The auto-increment operator has a little extra builtin magic t
+o it.

...(<i>special magic for incrementing strings, ie <c>++(\$x='x9') eq 'y
+0'</i>)...

"undef" is always treated as numeric, and in particular is chan
+ged to 0
before incrementing (so that a post-increment of an undef value
+ will
return 0 rather than "undef").

Cheers Rolf

Replies are listed 'Best First'.
Re^4: Numification of strings
by ikegami (Pope) on Aug 03, 2010 at 05:19 UTC
Orthogonal means unrelated, independent. For example, if the size of a fish is orthogonal to its coloring, knowing the colour of a fish sheds no information about its size and vice-versa.
> > wow incrementing with ++ is not orthogonal to +1!

My wording was bad, I meant that the break of symmetry of '++' and '+1' "lowers the orthogonality" of the language.

This comment from a Java board reflects my understanding of orthogonal:

Orthogonality is a boolean property. You have it or you don't. It is not a number or count. ...

What Wirth specifically meant was that Pascal control statements and declarations are independent of each other. This is the reason why Pascal compilers can be so small. See here.

The concept in programming languages comes from Van Wijngaarden's paper Orthogonal design and description of a formal language prepared for the Algol-68 group, in which he expressed the desire to 'see the definition of a (programming) language as the Cartesian product of its concepts'.

And if features of the concept of addition are not parallel, the product of the features becomes "less" Cartesian, i.e. one gets "more exceptions from the rule". That's my personal definition of "lowering orthogonality".

Cheers Rolf

UPDATE: to be more explicit:

```:~\$ perl -wde0
...
DB<1> my %a; \$a{1}=\$a{1}+1;print \$a{1}
Use of uninitialized value \$a{"1"} in addition (+) at (eval 5)[/usr/sh
+are/perl/5.10/perl5db.pl:638] line 2.
...
1
DB<2> my %a; \$a{1}++;print \$a{1}
1

in perl lingo you might say ++ has special magic!

If you were going by that definition, you would be wrong — they are independent, so they're orthogonal — and you might as well have said "the sky is blue" for its relevance to the rest of what you said. Orthogonality refers to independence, not similarity.

Create A New User
Node Status?
node history
Node Type: note [id://852465]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2018-05-24 08:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
World peace can best be achieved by:

Results (174 votes). Check out past polls.

Notices?