<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Yes that is my understanding.<br>
    <br>
    On 01/17/2012 01:43 AM, Veer Singh wrote:
    <blockquote
cite="mid:CANiex7pSBgqZJyE2gP56MWWbFb2VPGmpwkFM5zrSoZajMrO6JA@mail.gmail.com"
      type="cite">Thanks , I think I understand it now &nbsp;, so roughly
      following steps happens(apology for&nbsp;incorrect&nbsp;terminology) :
      <div><br>
        <div>1. bind the identifier 'phases' to some val(a syntax
          transformer) in phase 1</div>
        <div><br>
        </div>
        <div>&nbsp; &nbsp; i) &nbsp;during the above step id 'phase2' is bound to some
          val i.e syntax transformer in phase 2&nbsp;</div>
        <div><br>
        </div>
        <div>&nbsp; &nbsp; ii) (phase2) is expanded i.e it is looked up in phase 2
          and it's syntax transformer applied , which returns the syntax
          object which is basically #'0&nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;since cnt was 0 at the time of application of
          transformer.</div>
        <div><br>
        </div>
        <div>&nbsp; &nbsp;iii) &nbsp;step 1 done.</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>2. encounters macro call (set-compile) and expansion takes
          place and set cnt=1(phase 1) , cnt=2(phase 2).</div>
        <div><br>
        </div>
        <div>3. encounters macro call (phases) looks up in phase 1 and
          its transformer is applied and we get (list 1 0) , since</div>
        <div>&nbsp; &nbsp;(p1 cnt=1) and (p2 0).</div>
        <div>&nbsp;</div>
        <div><br>
          <br>
          <div class="gmail_quote">
            On Tue, Jan 17, 2012 at 12:51 PM, Jon Rafkind <span
              dir="ltr">&lt;<a moz-do-not-send="true"
                href="mailto:rafkind@cs.utah.edu">rafkind@cs.utah.edu</a>&gt;</span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"> I'm guessing a
                little bit but I think its because the `phases' macro is
                expanded at phase 2 before `set-compile' is called. If
                you put (set-compile) before the definition of `phases'
                then you get '(1 2).
                <div>
                  <div class="h5"><br>
                    <br>
                    On 01/17/2012 12:06 AM, Veer Singh wrote: </div>
                </div>
                <blockquote type="cite">
                  <div>
                    <div class="h5">
                      <div><br>
                      </div>
                      <div>
                        <div>Why macro call (phases) produces '(1 0) and
                          not '(1 2) ?</div>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div>
                        <div>(module mod1 racket</div>
                        <div>(require (for-syntax syntax/parse))</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;"mod-compile.rkt"))</div>
                        <div>(require (for-syntax&nbsp;</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (for-syntax syntax/parse racket
                          )))</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;"mod-compile.rkt")))</div>
                        <div>(provide set-compile phases)</div>
                        <div><br>
                        </div>
                        <div>&nbsp; ;For phase 1</div>
                        <div>&nbsp; (begin-for-syntax</div>
                        <div>&nbsp; &nbsp; (define cnt 0)</div>
                        <div>&nbsp; &nbsp;&nbsp;</div>
                        <div>&nbsp; (define (store! v)</div>
                        <div>&nbsp; &nbsp; (set! cnt v)))</div>
                        <div>&nbsp;&nbsp;</div>
                        <div>&nbsp; ;For phase 2</div>
                        <div>&nbsp; (begin-for-syntax (begin-for-syntax</div>
                        <div> &nbsp; &nbsp; (define cnt 0)</div>
                        <div>&nbsp; &nbsp;&nbsp;</div>
                        <div>&nbsp; (define (store! v)</div>
                        <div>&nbsp; &nbsp; (set! cnt v))))</div>
                        <div>&nbsp;&nbsp;</div>
                        <div>&nbsp; ;;set the value of "cnt" in phase1 and
                          phase2</div>
                        <div>&nbsp; (define-syntax (set-compile stx)</div>
                        <div>&nbsp; &nbsp; (syntax-parse stx</div>
                        <div>&nbsp; &nbsp; &nbsp; [(_) #'(begin</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(begin-for-syntax</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; in "cnt" in phase 1
                          cnt=1</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(store! 1)&nbsp;</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(begin-for-syntax</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; in "cnt" in phase 2
                          cnt=2</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(store! 2)))</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'done)]))</div>
                        <div>&nbsp;&nbsp;</div>
                        <div><br>
                        </div>
                        <div>&nbsp; ;;return the value of cnt in phase1 and
                          phase2</div>
                        <div>&nbsp; (define-syntax (phases stx)</div>
                        <div>&nbsp; &nbsp;&nbsp;</div>
                        <div>&nbsp; &nbsp; ;phase2 ???</div>
                        <div>&nbsp; &nbsp; (define-syntax (phase2 stx) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                          &nbsp;</div>
                        <div>&nbsp; &nbsp; &nbsp; (syntax-parse stx</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; [(_) (with-syntax ([p cnt])</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#'p)]))</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
                        <div>&nbsp; &nbsp; ;phase1 &nbsp; &nbsp;</div>
                        <div>&nbsp; &nbsp; (syntax-parse stx</div>
                        <div>&nbsp; &nbsp; &nbsp; [(_) (with-syntax ([p1 cnt]</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[p2 (phase2)])</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#'(list p1 p2))]))</div>
                        <div>&nbsp;&nbsp;</div>
                        <div>&nbsp; (set-compile)</div>
                        <div>&nbsp; (phases)</div>
                        <div>&nbsp; ;produces (list 1 0), but why not (list 1
                          2)&nbsp;</div>
                        <div>&nbsp;&nbsp;</div>
                        <div>)</div>
                        <div><br>
                        </div>
                      </div>
                      <div><br>
                      </div>
                      <div>Thanks</div>
                      <div><br>
                      </div>
                      <br>
                      <fieldset></fieldset>
                      <br>
                    </div>
                  </div>
                  <pre>____________________
  Racket Users list:
  <a moz-do-not-send="true" href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a>
</pre>
                </blockquote>
                <br>
              </div>
              <br>
              ____________________<br>
              &nbsp;Racket Users list:<br>
              &nbsp;<a moz-do-not-send="true"
                href="http://lists.racket-lang.org/users"
                target="_blank">http://lists.racket-lang.org/users</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>