Hi Timothy,

On Feb 12, 8:08 pm, Timothy Pratley <timothyprat...@gmail.com> wrote:

> What should happen when/if the seq arg doesn't contain the symbol? I
> believe how you currently handle it is correct and in the spirit of
> let-> (alternatively it could be reported as an error) however it may
> raise yet another possibility for pipe:
> (pipe 5 inc (+ 2) (+ ? 3) (+ 4 ? 2))
> ie: if the argument is a seq and doesn't contain ? then it is assumed
> to be a post argument, but if it does contain ? then can be explicitly
> a pre or mid argument.

The problem that I see with scanning for the special symbol &
inserting it when not found is that it really requires a single symbol
as the binding. But I think it's good for let-> to behave just like
let does -- no surprises -- which means arbitrary destructuring. So,
for example, if my binding is like

  (let-> [[a :as all] coll]
     (if (pred? a) (map func1 all) (map func2 all))
     some-final-func)

what should happen if the last form was (map some-final-func) instead
of some-final-func? Which symbol should be inserted into the form?

One answer is that instead of a symbol being inserted, the value would
be (this is what happens when the form isn't a list, .e.g. (let-> [a
"string"] .toUpperCase) => (.toUpperCase "string")). But that brings
the question of *where* to put it -- second, or last? We'd have to
decide to follow -> or pipe, & I don't know that one makes more sense
than the other.

I think it's most straightforward to require that one manually places
the symbol for all cases other than the non-list.

> Is it worth considering how (doto) fits into the picture? My initial
> observation is that (doto) is orthogonal in the sense that its primary
> use is for java object manipulation, and there is never a use case to
> have arguments in different places for that. So I suspect doto is
> irrelevant.

I agree -- doto assumes methods that mutate an object, & I think those
are always going to be of the form (.method object [args]).

Best,
Perry



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to