[Haskell-beginners] Re: Integer factorization

Sergey V. Mikhanov sergey at mikhanov.com
Fri Mar 13 06:48:30 EDT 2009


> A second, and my main reason for short names, or rather against long
> names, is that names should be to the point. None of the names
>   newPrimes
>   topPrime
>   doFactors
>   doFilter
> accurately describe the object they represent. The primes are not "new",
> the prime is not "on top". The "do" is a prefix does not carry a meaning
> either, it just conveys that  doFactors  has something to do with
> factors . This is best expressed by making  doFactors  a local
> definition in the where-block of  factors.

Those remarks are fine with me! I asked about the stylistic changes because
I came from the, hm, Java world and would like to avoid "writing familiar
things in unfamiliar language". In Java, factors() and doFactors() would be
a perfectly named methods: factors() is public, auxiliary doFactors() is
private and essentially _does_ the factoring.

> > Out of curiosity, there is any reason why you called the auxiliary
> function
> > 'go' ?
> Convention. Often, an auxiliary function that does basically the same
> thing as the main function  factors  but with an extra parameter will be
> named  factors' . The apostrophe has the drawback that it's easy to
> forget, so some people now name such auxiliary functions  go  instead.

I think having a local function 'go' in 'factors' is aboslutely plausible:
it is local, there's no ambiguity.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090313/74eea645/attachment.htm

More information about the Beginners mailing list