A
Andrew
Hi, fellow perlers
Before posting this I spent some time googling the web at large as well as searching this group's archive for posts related to the idea I wish to express, and, on cursory search, have not found any post, to date, which expresses the following -- assertively and emphatically. Yet, I feel (I compute), it DOES need to be said, emphatically:
I absolutely, unequivocally LOVE, support and herald (as in, "Hats off to Larry Wall's genius") the syntactical distinction Perl5 (and older) makes between SINGULARITY and MULTIPLICITY. Syntactically, per se. In other words, EXPLICITLY, by means of two distinct symbols ("$" and "@"). The additional syntax that deals with the INTERPLAY between singular and multiple is equally brilliant:
$array[3]
@array[3,4,5]
(the pre-pended symbols instantly signal (to the human reader) whether we are dealing with a multiplicity version of 'array' or just one of its elements (which is a scalar))
The brilliant play with "@" (plural) and "$" (singular) continues (in termsof language design), with:
@array[@cherry_picked_indexes]
and then, the whopper:
@hash{@list_of_keys} or @hash{qw(yada dooba boom}}
and then the enormously convenient (and code-economical) flexibility of nesting all of the above in a gazillion ways:
@hash{@{$two_dimensional[3]}}
@hash_one{keys %hash_two}
etc, etc, etc!
-----------------
So, the converse of my exuberance over this syntactical excellence of Perl5(as I assess it to be) is my complete bewilderment and puzzlement (puttingit mildly) over PHP's LACK of such distinction (syntactically) between singularity and multiplicity.
in PHP,
$this_could_be_a_scalar
and
$this_could_be_an_array
I believe (correct me if I'm wrong) that in PHP I am left guessing, by context, whether I'm looking at a scalar or an array.
So, I can only bash my head against the wall (note: LOWER-case "wall"), over the notion that not only does PHP's shortcoming (the lack of such succinct syntactical acrobatics as I've tried to suggest above, with the nested arrays and hashes in Perl) has gone COMPLETELY unnoticed (ignored/forgiven/even embraced as solid standard!?), I have learned (again, please correct me if I am wrong) that Perl itself (!!!) -- in its new and radically revised VERSION 6, is tossing out this baby with the bath water -- this gem of a syntax, obliterating the "$" versus "@" distinction, and (as I would put it) is descending to the painfully banal and ambiguous "$" for both scalars and arrays (?!) (that we observe in PHP)
I would also like to add that "singular versus plural" (one versus many) isunequivocally a FUNDAMENTAL dichotomy, NOT JUST in computer programming, but in human (natural) language and human psychology and logical processing/thinking. (Perhaps on a par with "zero versus one", or "existing versus non-existing", etc., but just as fundamental)
The syntactical differentiation has given us clarity and absence of ambiguity.
So there, I've said it. I hope it did NOT come across as a rant, but more as a rallying cry... at least a rallying to acknowledge the value of the "$" and "@" syntax and the fact that losing it would mean losing a whole lot of clever, succinct, and quintessentially Perl coding freedom and flexibility.
Before posting this I spent some time googling the web at large as well as searching this group's archive for posts related to the idea I wish to express, and, on cursory search, have not found any post, to date, which expresses the following -- assertively and emphatically. Yet, I feel (I compute), it DOES need to be said, emphatically:
I absolutely, unequivocally LOVE, support and herald (as in, "Hats off to Larry Wall's genius") the syntactical distinction Perl5 (and older) makes between SINGULARITY and MULTIPLICITY. Syntactically, per se. In other words, EXPLICITLY, by means of two distinct symbols ("$" and "@"). The additional syntax that deals with the INTERPLAY between singular and multiple is equally brilliant:
$array[3]
@array[3,4,5]
(the pre-pended symbols instantly signal (to the human reader) whether we are dealing with a multiplicity version of 'array' or just one of its elements (which is a scalar))
The brilliant play with "@" (plural) and "$" (singular) continues (in termsof language design), with:
@array[@cherry_picked_indexes]
and then, the whopper:
@hash{@list_of_keys} or @hash{qw(yada dooba boom}}
and then the enormously convenient (and code-economical) flexibility of nesting all of the above in a gazillion ways:
@hash{@{$two_dimensional[3]}}
@hash_one{keys %hash_two}
etc, etc, etc!
-----------------
So, the converse of my exuberance over this syntactical excellence of Perl5(as I assess it to be) is my complete bewilderment and puzzlement (puttingit mildly) over PHP's LACK of such distinction (syntactically) between singularity and multiplicity.
in PHP,
$this_could_be_a_scalar
and
$this_could_be_an_array
I believe (correct me if I'm wrong) that in PHP I am left guessing, by context, whether I'm looking at a scalar or an array.
So, I can only bash my head against the wall (note: LOWER-case "wall"), over the notion that not only does PHP's shortcoming (the lack of such succinct syntactical acrobatics as I've tried to suggest above, with the nested arrays and hashes in Perl) has gone COMPLETELY unnoticed (ignored/forgiven/even embraced as solid standard!?), I have learned (again, please correct me if I am wrong) that Perl itself (!!!) -- in its new and radically revised VERSION 6, is tossing out this baby with the bath water -- this gem of a syntax, obliterating the "$" versus "@" distinction, and (as I would put it) is descending to the painfully banal and ambiguous "$" for both scalars and arrays (?!) (that we observe in PHP)
I would also like to add that "singular versus plural" (one versus many) isunequivocally a FUNDAMENTAL dichotomy, NOT JUST in computer programming, but in human (natural) language and human psychology and logical processing/thinking. (Perhaps on a par with "zero versus one", or "existing versus non-existing", etc., but just as fundamental)
The syntactical differentiation has given us clarity and absence of ambiguity.
So there, I've said it. I hope it did NOT come across as a rant, but more as a rallying cry... at least a rallying to acknowledge the value of the "$" and "@" syntax and the fact that losing it would mean losing a whole lot of clever, succinct, and quintessentially Perl coding freedom and flexibility.