Alan Manuel Gloria noted that with:
> (cond
> ((< x -1) (* x x))
> ((> x 1) (* x x))
> ((< x 0) (sqrt (abs x)))
> (else (sqrt x)))
>
> ..without $, we'd have to use:
>
> cond
> (< x -1)
> * x x
> (> x 1)
> * x x
> (< x 0)
> sqrt (abs x)
> else
> sqrt x
>
> ...with $:
>
> cond
> (< x -1) $ * x x
> (> x 1) $ * x x
> (< x 0) $ sqrt $ abs x
> else $ sqrt x
To be fair, I would write this particular case using parens and infix, as:
cond
! {x < -1} {x * x}
! {x > 1} {x * x}
! {x < 0} sqrt(abs(x))
! else sqrt(x)
> but if you're using multiple expressions, you should really be using
> indentation anyway.
Fair enough.
> (admittedly, you can also just retain the parentheses, but every
> parenthesis cuts the power of t-expressions, because parentheses
> disables stuff.)
Well, it only disables indentation-processing stuff; you still have infix,
traditional function application, and n-expression suffixes.
Since this case just uses parens for traditional functional application, and
it's not deeply nested, I'd do it the other way as I've shown above. This is
one of those situations where there are 2 good ways; both are reasonable. I
think *EITHER* approach is an improvement over traditional notation.
> I feel "$" is a really good balance of something-weird (con) but
> extremely useful (pro).
I think "$" is *not* really something weird, because it's already in an
existing language with significant use (Haskell). Granted, someone who's never
used Haskell has something new to learn. But practically all programming
languages have a large set of infix operations; from that point of view,
t-expressions have a remarkably tiny set of special "infix" operations.
--- David A. Wheeler
------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Readable-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/readable-discuss