Important coding guideline and library proposal

Guideline: NEVER, *never ever*, use 'length' ***unless you really want to know the exact length of a list*** Proposal: rename 'length' to 'yesIReallyWantToKnowTheExactLengthOfThisListSoPleaseCalculateItForMe' to reduce performance bugs caused by naive uses of length.

Well then, on a similar note, I propose the following name changes: (+) is now "yesIShouldReallyLikeToKnowTheSumOfTheseTwoThingsOverWhichTheOperationOfSummationIsDulyAndTotallyDefined " (-) is the same, but with "Summation" changed to "AdditiveInverseAndSummation" the `do` construct ought to be renamed "doThisMonadicComputationForMePleaseByDesugaringThisConvienentNotationAndTurningItIntoASequenceOfBindFunctionsAndLambdaAbstractionsSuchThatMyIntendedMeaningInFactIsReflected " Further, things like "unsafePerformIO" is not nearly descriptive enough, however, I leave it's appropriate renaming as an exercise to the reader... /Joe On Nov 22, 2009, at 2:15 PM, Daniel Fischer wrote:
Guideline:
NEVER, *never ever*, use 'length' ***unless you really want to know the exact length of a list***
Proposal: rename 'length' to 'yesIReallyWantToKnowTheExactLengthOfThisListSoPleaseCalculateItForMe' to reduce performance bugs caused by naive uses of length. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

I should think the more obvious examples would be last and init...
Michael
On Sun, Nov 22, 2009 at 9:26 PM, Joe Fredette
Well then, on a similar note, I propose the following name changes:
(+) is now "yesIShouldReallyLikeToKnowTheSumOfTheseTwoThingsOverWhichTheOperationOfSummationIsDulyAndTotallyDefined"
(-) is the same, but with "Summation" changed to "AdditiveInverseAndSummation"
the `do` construct ought to be renamed "doThisMonadicComputationForMePleaseByDesugaringThisConvienentNotationAndTurningItIntoASequenceOfBindFunctionsAndLambdaAbstractionsSuchThatMyIntendedMeaningInFactIsReflected"
Further, things like "unsafePerformIO" is not nearly descriptive enough, however, I leave it's appropriate renaming as an exercise to the reader...
/Joe
On Nov 22, 2009, at 2:15 PM, Daniel Fischer wrote:
Guideline:
NEVER, *never ever*, use 'length' ***unless you really want to know the exact length of a list***
Proposal: rename 'length' to 'yesIReallyWantToKnowTheExactLengthOfThisListSoPleaseCalculateItForMe' to reduce performance bugs caused by naive uses of length. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Hi Daniel
Hmm, maybe the docs in Data.List should say that length is recursively
calculated. I know you can view the source from Haddock, and its also
obvious once you think of list as being defined by an algebriac type,
but lists in other languages (read OO) often have track length as part
of the ADT making it constant time to get hold of.
Best wishes
Stephen
2009/11/22 Daniel Fischer
Guideline:
NEVER, *never ever*, use 'length' ***unless you really want to know the exact length of a list***
Proposal: rename 'length' to 'yesIReallyWantToKnowTheExactLengthOfThisListSoPleaseCalculateItForMe' to reduce performance bugs caused by naive uses of length. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

... or just say that it's O(n) in the docs. And if n is infinity
you'll be waiting for a while.
(Sorry Stephen... meant that for the list)
On Sun, Nov 22, 2009 at 2:33 PM, Stephen Tetley
Hi Daniel
Hmm, maybe the docs in Data.List should say that length is recursively calculated. I know you can view the source from Haddock, and its also obvious once you think of list as being defined by an algebriac type, but lists in other languages (read OO) often have track length as part of the ADT making it constant time to get hold of.
Best wishes
Stephen
2009/11/22 Daniel Fischer
: Guideline:
NEVER, *never ever*, use 'length' ***unless you really want to know the exact length of a list***
Proposal: rename 'length' to 'yesIReallyWantToKnowTheExactLengthOfThisListSoPleaseCalculateItForMe' to reduce performance bugs caused by naive uses of length. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- keithsheppard.name

Am Sonntag 22 November 2009 20:43:54 schrieb Keith Sheppard:
... or just say that it's O(n) in the docs. And if n is infinity you'll be waiting for a while.
http://hackage.haskell.org/trac/ghc/ticket/3680 Ticket opened.

Am Sonntag 22 November 2009 20:33:21 schrieb Stephen Tetley:
Hi Daniel
Hmm, maybe the docs in Data.List should say that length is recursively calculated.
I never noticed the docs didn't say anything about the complexity of length. That should indeed be mentioned.
I know you can view the source from Haddock, and its also obvious once you think of list as being defined by an algebriac type, but lists in other languages (read OO) often have track length as part of the ADT making it constant time to get hold of.
Which of course is not easy for infinite lists, even harder for lists of which you don't know yet whether they're finite or not (list of prime-twins, e.g.).
Best wishes
Stephen
2009/11/22 Daniel Fischer
: Guideline:
NEVER, *never ever*, use 'length' ***unless you really want to know the exact length of a list***
Proposal: rename 'length' to 'yesIReallyWantToKnowTheExactLengthOfThisListSoPleaseCalculateItForMe' to reduce performance bugs caused by naive uses of length.

2009/11/22 Daniel Fischer
I never noticed the docs didn't say anything about the complexity of length. That should indeed be mentioned.
Maybe not too usual, neither the OCaml or MzScheme docs mention that length is not constant time (caveat - I'm not at the latest release of either). Actually I was a bit surprised that getting the length in MzScheme was an iterative calculation rather than constant-time lookup, it's something I never noticed in years of using MzScheme. http://caml.inria.fr/cgi-bin/viewcvs.cgi/ocaml/trunk/stdlib/list.ml?rev=7597&view=markup http://svn.plt-scheme.org/plt/trunk/src/mzscheme/src/list.c see scheme_list_length Best wishes Stephen

On Nov 22, 2009, at 15:25 , Stephen Tetley wrote:
2009/11/22 Daniel Fischer
: I never noticed the docs didn't say anything about the complexity of length. That should indeed be mentioned.
Maybe not too usual, neither the OCaml or MzScheme docs mention that length is not constant time (caveat - I'm not at the latest release of either).
But laziness means that it's not always obvious what time complexity a given function has, so it's a good idea to document it in all cases. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

G'day all.
Quoting Daniel Fischer
Proposal: rename 'length' to 'yesIReallyWantToKnowTheExactLengthOfThisListSoPleaseCalculateItForMe' to reduce performance bugs caused by naive uses of length.
genericYesIReallyWantToKnowTheExactLengthOfThisListSoPleaseCalculateItForMe Another option is to rename Data.List to Data.List.YesIKnowThisIsNotAnArray. Cheers, Andrew Bromage
participants (7)
-
ajb@spamcop.net
-
Brandon S. Allbery KF8NH
-
Daniel Fischer
-
Joe Fredette
-
Keith Sheppard
-
Michael Snoyman
-
Stephen Tetley