On 1/17/13, Alan Manuel Gloria <almkg...@gmail.com> wrote:
> On 1/17/13, David A. Wheeler <dwhee...@dwheeler.com> 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:

        ((< x -1) (* x x))
        ((> x 1) (* x x))
        ((< x 0) (sqrt (abs x)))
        (else (sqrt x)))

..without $, we'd have to use:

        (< x -1)
                * x x
        (> x 1)
                * x x
        (< x 0)
                sqrt (abs x)
                sqrt x

...with $:

        (< 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)

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


I feel "$" is a really good balance of something-weird (con) but
extremely useful (pro).


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:
Readable-discuss mailing list

Reply via email to