Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mdo syntax #1

Open
robertluo opened this issue Jun 15, 2013 · 1 comment
Open

mdo syntax #1

robertluo opened this issue Jun 15, 2013 · 1 comment
Assignees

Comments

@robertluo
Copy link

The mdo syntax seems like alien in clojure world. especially for the let form. What if we change it to:

(mdo {:keys [x y]}  <- get-state
     :let [z (+ (* x x) (* y y))]
     (modify assoc :z z)
     (return z))

The :let form looks for consistent with for, doseq.
Also for modify function, is better to enable (modify [f & params]) style?

@ghost ghost assigned bwo Jun 18, 2013
@bwo
Copy link
Owner

bwo commented Jun 18, 2013

Yes, I've thought the same about modify and friends, and will probably do it.

I actually find the for, doseq etc. let syntax kind of gross, tbh; anyway, you don't need to use the admittedly kind of conspicuous let-syntax that mdo supports; you could also write:

(mdo {:keys [x y]} <- get-state
     (let [z (+ (* x x) (* y y)]
       (modify assoc :z z)
       (return z)))

But I admit that it may be found desirable to have an inline form such as already exists (or as you suggest). But I still don't really like the form you suggest (no offense), partly because the rest of the syntax diverges from customary Lisp style anyway (with, I think, good reason). But it occurred to me recently that there's no reason for the supporting parsers that mdo exploits to live in a separate package, so I'll probably move them out of there and into this one, making it easier to support alternate styles---it's really quite simple.

(Basically, I don't like having :let be a keyword, and I don't like the use of a binding vector there where it looks, to me, to be floating around not really connected to anything. The let x = (+ (* x x) (* y y)) syntax is clearer to me both as regards what the assignee is and what the expression is,and that the whole thing is not happening in a "normal" execution context---whereas we'd normally expecting the binding only to be visible in what the let form encloses, here the let form (before the transformation) doesn't enclose anything. Maybe it's because the whole mdo syntax apes Haskell's do syntax anyway, but it looks nicer to me. As I said, you don't have to use it at all.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants