On 1/17/13, Alan Manuel Gloria <[email protected]> wrote:
> On 1/17/13, David A. Wheeler <[email protected]> wrote:
>>> Personally I'm not (yet?) a big fan of $.
>>
>> Not a problem. It's grown on me. Once you have it, you find that
>> patterns
>> where it applies are remarkably common.
>
> (^^)v
>
In support of that, consider the following:
(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
...which is a lot nearer to the original s-expression. The only
caveat is that in this form, $ is followed by a *single* expression,
but if you're using multiple expressions, you should really be using
indentation anyway.
(admittedly, you can also just retain the parentheses, but every
parenthesis cuts the power of t-expressions, because parentheses
disables stuff.)
Here's a better example of the intended use of $:
import $ srfi srfi-45
import $ amkg object
; use for debugging
define probe(x)
print(x)
x
define lazy-construct(a d)
lazy $ probe $ let ((rv #f))
set! rv $ object-construct 'cons-cell
object-method-register rv
'car $ lambda () a
'set-car! $ lambda (na) $ set! a na
'cdr $ lambda () d
'set-cdr! $ lambda (nd) $ set! d nd
rv
--
I feel "$" is a really good balance of something-weird (con) but
extremely useful (pro).
Sincerely,
AmkG
------------------------------------------------------------------------------
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