<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Here we have an interesting interaction
      between the ordering of compiler phases.<br>
      <br>
      Ur/Web links (including in <submit> actions) must be calls
      to named functions defined at the top levels of modules, more or
      less.  While the body of [sbm] instead uses a local variable for a
      link, we know, of course, that inlining the definition of [sbm]
      leads to a concrete function name instead.  Unfortunately, the
      current Ur/Web compiler is not going to inline the call, because
      the phase that does inlining runs <i>after</i> the phase that
      produces URL-generation code!  I think this ordering choice is
      actually the right one, because inlining can change which
      syntactic function name appears in an 'action' attribute, etc.,
      potentially leading to unintuitive behavior in URL generation
      (e.g., a link written as a call to a particular named function
      actually winds up compiled as a call to different named function,
      because of inlining).<br>
      <br>
      Probably the easiest way to implement your abstraction is via a
      functor, using the module system.  Functor applications get
      inlined fully before producing URL-generation code.<br>
      <br>
      Even better, though, could be to stop using 20th-century forms and
      use client-side scripting with <button>, etc., instead!<br>
      <br>
      On 07/20/2014 04:08 PM, Sergey Mironov wrote:<br>
    </div>
    <blockquote
cite="mid:CAMOkk_ac2WGwLV9dfrR-rcFJ-EdFANgU=rJpiOzuoRtWGKExqQ@mail.gmail.com"
      type="cite">
      <pre wrap="">Hi! Here is another error I've faced when trying to write a
styling-wrapper for my submit buttons:

$ urweb -dbms sqlite Submit
/home/grwlf/proj/urbugs/Submit.ur:21:89: (to 21:90) Invalid Action expression
Expression UNBOUND_0

See the trivial example below. Please, consider fixing! Without
sbm-like wrappers I am forced to repeat submit code from form to
form..
Regards,
Sergey

--

style mystyle

con ct = [A = string, B = string]

fun handler (x:$ct) : transaction page = return
<xml><head/><body>{[x.A]}{[x.B]}</body></xml>

fun sbm [t:::{Type}] (h : $t -> transaction page) : xml form t [] =
<xml><div class={mystyle}><submit action={h}
value="Send"/></div></xml>

fun main {} = return <xml><head/><body>
  <br/>
  <form>
  <textbox{#A}/>
  <textbox{#B}/>
  {sbm handler}
  </form>
  </body></xml>
</pre>
    </blockquote>
  </body>
</html>