[ale] perl, python, C, C++ old code readability
Joseph A Knapka
jknapka at earthlink.net
Fri Feb 15 05:17:25 EST 2002
"James P. Kinney III" wrote:
>
> I would posit that one the biggest drawbacks to Perl is that it is
> clearly an evolved language. Its beginnings were simple enough. But as
> more ways to use it were found, it grew in complexity. It is very easy
> to write unintelligible code in Perl. It is also easy to not write that
> way. The moniker "Swiss army chainsaw" is not a joke! But this "there is
> more than one way to do it" is a main cause for obfuscation in Perl.
Here's a Python Enhancement Proposal posted to the Anygui
development list recently:
---begin quote---
From: Greg Ewing <greg at cosc.canterbury.ac.nz>
To: ale at ale.org
To: devel at anygui.org
Laura Creighton <lac at strakt.com>:
> Never discount the 'showing off that I know how to use slice
> is cool' factor.
> There are days I truly wish there really was ONLY ONE WAY
> TO DO IT.
PEP 9002: Reducing number of ways to copy a sequence
ABSTRACT
This PEP proposes modifications to the language and standard
library to reduce the variability in the way sequence copying
operations are expressed.
MOTIVATION
Laura Creighton thinks there are too many ways to copy
a list.
DETAILED PROPOSAL
The following changes will be made:
(1) Attempting to use a slice operation to retrieve the
entire contents of a sequence, or to apply the builtin
list() type constructor or the copy.copy() function to a
sequence [see note 1], will cause the raising of a
ThisWayOfDoingItNoLongerSupportedError exception.
(2) The compiler will be made to detect and reject any
apparent attempts to copy a sequence using a loop,
list comprehension or recursive function. The exception
NaughtyProgrammerTryingToDoItHisOrHerOwnWayError will be
raised.
(3) The builtin sequence types will have added to them a
new method makeacopyofthistheoneandonlytrueway(), which
will return a copy of the sequence. A new builtin type
'sequence' supplying this functionality will be provided
for use as a base class by user-defined classes.
NOTES
[1] Determination of whether a given object is a sequence
will be by means of heuristics such as testing for the
presence of __len__, __getitem__ and __getslice__ methods.
If these tests are inconclusive, the system will automatically
send an email to Laura Creighton asking whether the operation
should be allowed, with a pickle of the offending object together
with relevant excerpts from the source code attached, and
await a reply in a suitably standardised format. Although
this will introduce some delay into running programs, it
is believed this will be a small price to pay for the
benefits accrued in terms of increased code clarity and
uniformity.
Discussion invited.
---end quote---
Cheers,
-- Joe
"I should like to close this book by sticking out any part of my neck
which is not yet exposed, and making a few predictions about how the
problem of quantum gravity will in the end be solved."
--- Physicist Lee Smolin, "Three Roads to Quantum Gravity"
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list