[Haskell-cafe] Language complexity & beginners
Bryan Richter
b at chreekat.net
Tue Feb 9 17:12:40 UTC 2016
On Tue, Feb 09, 2016 at 02:27:44PM +0300, Kosyrev Serge wrote:
> Michael Orlitzky <michael at orlitzky.com> writes:
> > Most uses of "$" are for stupid
> > things like "sin $ 1 + 2" where parentheses would be much more clear.
>
> "$" simplifies visual perception through two factors:
>
> 1. we are relieved from counting parentheses
> 2. it serves as a cue to treat the entire remaining part until ")" as
> part of the same expression
>
> Case in point (only slightly contrived) -- which one is easier to
> visually parse to you:
>
> foo (thInt $ fromIntegral $ c2hsValueInt cexp) (thInt $ fromIntegral $ c2hsValueInt cexp)
>
> foo (thInt (fromIntegral (c2hsValueInt cexp))) (thInt (fromIntegral (c2hsValueInt cexp)))
My readability problem with this statement is line length. How about:
foo (thInt (fromIntegral (c2hsValueInt cexp)))
(thInt (fromIntegral (c2hsValueInt cexp)))
I apologize for playing syntax golf, but I do want to cast a small
vote for preferring parentheses over ($). It is this preference that
makes me side with Orlitzky's argument that the type of ($) is
irrelevant for beginners, since beginners should be encouraged to use
parentheses anyways. It's One Less Thing To Worry About(tm).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160209/d5e2ac9e/attachment.sig>
More information about the Haskell-Cafe
mailing list