[racket-dev] P4P: A Syntax Proposal

From: Everett (webj2 at unoc.net)
Date: Thu Jul 29 13:16:20 EDT 2010

So the dotted style is a shortcut for
(let ([a $B("name")])
  (let ([b changes(a)])
    (let ([c calmE(b 300)])
      c)))
which is another way to show the sequential nature of the data flow.

As a macro you can write:

(define-syntax-rule (. var exp next)
  '(let ([,var ,exp]) next))

(. b (. a $B("name") changes(a)) calmE(b 300))

And that also looks similar.  No idea if this is any help...

-Everett

On Thu, 2010-07-29 at 10:00 -0700, Joe Marshall wrote:
> On Wed, Jul 28, 2010 at 3:27 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> > Quoting from our Flapjax paper (pg 12):
> > This means that instead of
> >
> >  var name = calmE(changes($B("name")), 300);
> >
> > developers can write
> >
> >  var name = $B("name").changes().calmE(300);
> >
> > which is arguably more readable than standard functional notation,
> > since the left-to-right order of operations corresponds to the
> > direction of dataflow.
> >
> > -----
> >
> > What I didn't admit there is that *I* prefer the dotted style for this
> > kind of sequential pipeline.
> 
> There are a couple of serious problems with the dotted style.  First,
> in most languages that use this notation, the `method name' (the token
> immediately after the dot) is scoped within the class of the object.  Methods
> are generally *not* first-class objects.  This means that you cannot write
> something like:
>   deffun: callit (object, method) =
>     object.method()
> 
> The second problem is that what is *really* happening is a function call,
> but the first (or second, depending how you count) argument is for some
> unexplained reason separated from the others and placed in a weird position.
> For example, in this:
>   >  var name = $B("name").changes().calmE(300);
> 
> Is it immediately obvious to you that calmE takes *two* arguments?
> Can you explain why the second argument isn't treated the same way?
> 
> -- 
> ~jrm
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/dev



Posted on the dev mailing list.