Double Evaluation in $ macro

Bug #518147 reported by Stardom
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ken Dickey
Fix Released
Undecided
Unassigned

Bug Description

Currently, the macro is defined as
;; [$ <selector-sym> <obj> <arg> ...]
(define-syntax $ ;; send [user syntax]
  (syntax-rules ()
    [($ <selector> <obj> <arg> ...)
     ;;=>
     ((-> '<selector> <obj>) <obj> <arg> ...)
    ]
) )

<obj> is repeated twice which causes double evaluation.

Revision history for this message
Ken Dickey (ken-dickey) wrote :

I have never seen a case in practice where a general expression is used for <obj> rather than an object reference (a variable naming an object).

It is certainly a trivial change to add the let, e.g.

(define-syntax $ ;; send [user syntax]
  (syntax-rules ()
    [($ <selector> <obj> <arg> ...)
     ;;=>
     (let [(obj <obj>)]
       ((-> '<selector> obj) obj <arg> ...))
    ]
) )

I would be interested to know the context of the problem.

Thks,
-KenD

Revision history for this message
Stardom (seth-tewebs) wrote :

I was doing some tests and was passing it an object which took approximately .4 seconds to compute by itself. So i was then wondering why it took .8 seconds when I directly passed the object in. Also, I imagine any function that has side effects might also create a bug in the program.

Revision history for this message
Ken Dickey (ken-dickey) wrote :

Fixed in revision 36 -- Thanks!

Changed in kend:
status: New → Fix Committed
Ken Dickey (ken-dickey)
Changed in kend:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.