Arc Forumnew | comments | leaders | submitlogin
2 points by almkglor 6160 days ago | link | parent

Hmm. Personally, if I wanted to do this, I'd do the point macro myself manually, i.e.

  (point return
    (while (something)
        (aif (something-else) (return it))))
The problem, you see, is breaking out of nested loops:

  (point return
     (while (something)
        (if (some-condition)
            (while (something-in-condition)
               (aif (some-other-condition) (return it))))))
Personally, while I do find this quite a good idea, I think it happens rarely enough that the 'point trick should be recommended in a tutorial, but not build-in a (point break ...) in each loop. Just my gut feel though.


1 point by sjs 6159 days ago | link

I was thinking the same thing this morning actually. Probably not something common enough to warrant wrapping every loop. I like the breakable idea of yours.

-----

2 points by almkglor 6159 days ago | link

Could be implemented. I'm in the office right now so I can't use arc here (mandatory windows pc, not to mention a shared internet terminal); it would be possible to just add it into arc.arc, although with a seriously good docstring.

  (mac breakable (expr)
    " Creates a control structure which can be exited by
      calling `break' with a value to be returned.  To
      use, add `breakable:' before the control structure,
      e.g. (breakable:while t (aif (something) (break it)))
      See also [[catch]] [[point]] [[compose]] [[while]] "
      `(point break ,expr))

-----