Well, this is an interesting idea: using locales as stack frames. It has one problem that the locale context is switched and you lose business definitions, thus need to reference _base_. This might be resolved possibly by coinserting the business locale into "stack frame" locale. But it still might be disruptive because of assignments.
An alternative solution would be follow the JHP model that, as in application server, code runs in a container, that is an environment that sets up a context. But the context is static, it does not get nested like stack frame. Here this context is the output stream, which is used by the static print verb. Another task of the context would be catch errors and do recovery. Note: '''''' is '$0' NB. ========================================================= require 'web/jhp' print=: 3 : '$0[r=: r,padj y' println=: 3 : '$0[r=: r,LF,~ padj y' run=: 3 : 0 r=: '' verb hdef y '' r ) male=: verb hdef 'Mr. <%= y %>' couple=: dyad hdef '<% male x %> and Mrs. <%= y %>' Note 'test' run 'qq <%=1+1%> zz' run 'qq <%= male ''one''%> zz' run 'qq <%= ''one'' couple ''two''%> zz' ) NB. ========================================================= run 'qq <%=1+1%> zz' qq 2 zz run 'qq <%= male ''one''%> zz' qq Mr. one zz run 'qq <%= ''one'' couple ''two''%> zz' qq Mr. one and Mrs. two zz couple 4 : 0 male x print ' and Mrs. ' print y ) --- June Kim <[EMAIL PROTECTED]> wrote: > Thank you for the hint. Following is my attempt at using locales. Any > suggestions for improvement? > > require 'web/jhp' > > v2=: 3 : 0 > (monad hdef2 y) '' > ) > > hdef2=: 2 : 0 > '' m hdef2 n y > : > start=.coname '' > cocurrent this=. cocreate '' > r=: '' > print=: 3 : '''''[r=: r,padj y' > println=: 3 : '''''[r=: r,LF,~ padj y' > x 4 : (hrep n) y > here=. r > cocurrent start > coerase this > here > ) > > male=: monad hdef2 'Mr. <%= y%>' > couple=: dyad hdef2 'Mr. <%=x%> and Mrs. <%=y%>' > he=:person=: 'Joe' > she=:'Jane' > v2 'Hello, <%=male_base_ person_base_%>!' > Hello, Mr. Joe! > v2 'Hello, <%=he_base_ couple_base_ she_base_%>!' > Hello, Mr. Joe and Mrs. Jane! > > > 2007/5/28, Raul Miller <[EMAIL PROTECTED]>: > > On 5/27/07, June Kim <[EMAIL PROTECTED]> wrote: > > > Maybe, using locales is better? > > > > I'd think so. > > > > Try putting > > cocurrent this=.cocreate'' > > at the top of v, and > > coerase this > > on the second to last line. > > > > Note, however, that any "globally defined names" must be > > qualified with their locale (for example base) if they're not in z, > > if you want to reference them from jhp text which is used in > > this fashion. > > > > -- > > Raul > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ____________________________________________________________________________________ It's here! Your new message! Get new email alerts with the free Yahoo! Toolbar. http://tools.search.yahoo.com/toolbar/features/mail/ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
