Uploaded image for project: 'Clojure'
  1. CLJ-1121

-> and ->> have unexpected behavior when combined with unusual macros

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: Release 1.5
    • Fix versions: Release 1.6
    • Labels:
      None
    • Approval:
      Ok
    • Patch:
      Code and Test

      Description

      My intuitive understanding of the classic threading macros is that the meaning of forms like (-> a b c) can be understood syntactically independent of the meaning of the symbols involved or the fact that the two threading macros are defined recursively. However the recursive definition breaks that expectation. After

      (macroexpand-1 (macroexpand-1 '(-> a b c)))
      
      => (c (-> a b))
      

      c is now in control if it is a macro, and is now seeing the argument (-> a b) rather than (b a) as would be the case if we had written (c (b a)) originally.

      Admittedly I do not know of a realistic example where this is an important distinction (I noticed this when playing with a rather perverse use of ->> with macros from korma), but at the very least it means that the behavior of the threading macros isn't quite as easy to accurately explain as I thought it was.

        Attachments

          Activity

            People

            • Assignee:
              stu Stuart Halloway
              Reporter:
              gfredericks gfredericks
            • Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: