From: Ralph T. <ra...@gm...> - 2006-02-12 22:06:06
|
Having "ordered unnamed dictionary entries" for virtual_machine functions is good, and really good in the case of an xstring_subst function (and you're right, even just using a dictionary is far better than what I was proposing as it syntactically suggests that unique substitution keys are required [as well as being far prettier]). One distant future thing that I've been thinking about for a while is abstracting out some of the policy that client_assembler bakes into widgets, for example we currently have things like: panel( bind: @named_value, value: "show_panel" ) { ... } meaning that the panel is displayed when @named_value is "show_panel"; but what if I wanted to show the panel whenever @named_value !=3D "show_panel"? I could put a rule into the sheet for this, but would this be better? panel( visible: @named_value !=3D "show_panel" ) { ... } or even to remove visibility from the panel totally: visible( predicate: @named_value !=3D "show_panel" ) { panel() { ... } } If you took this idea to it's logical extent (breaking everything down into atoms) could you define all/most of the widgets in terms of these atoms? All of the button-type things would be easy, a checkbox might be: define_widget( "checkbox", parameters: { name: @cb_name, bind: @cb_value } = ) { row() { /* how to put "indeterminate" value in here for mousedown (but not clicked) */ action( activate: @cb_value =3D !@cb_value ) { overlay() { visible( predicate: @cb_value =3D=3D true ) { image( src: "checked"= ); } visible( predicate: @cb_value =3D=3D false ) { image( src: "uncheck= ed" ); } } static_text( name: @cb_name ); } } } (and then you can use "checkbox" as you currently do, but it's actually just parameterizing the above definition each time -- @cb_name and @cb_value get replaced; so checkbox( name: "foo", bind: @my_cell ) means that @cb_name is replaced by "foo" and @cb_value is replaced by @my_cell). If it were possible to implement all of the widgets in ui-core in terms of a small set of atoms (and have a "ui-core prelude file" that defines all of the ui-core widgets, like checkbox above) then implementing new widgets (such as those proposed in the wiki) should mostly be a matter of combining existant atoms (and hopefully atom implementation is easy enough that adding a new one is still less work than writing a widget for N platforms). This "atomic toolkit" idea is clearly only 1/3 baked, I might try to write a simple implementation of this in Mission to learn more about the problems involved. Ralph On 2/11/06, Sean Parent <sp...@ad...> wrote: > Foster is the xstring export so I'll let him answer - I suspect we're > missing an API (I'd rather not have to go through a context for > replacement) - but I think you should be able to simply create a > local context as a workaround. I believe you also want to be using > the marker mechanism for the replacement (Foster?). > > For the xstring_sub function call - I don't think you are getting any > benefit by referring to cells by a quoted name then looking it up > manually - you can simply use the cell as a variable name. I'd > recommend making it a function taking named parameters - > > xstring_replace(string: "<xstr id=3D'string'><marker id=3D'text'/> the > number is <marker id=3D'num'/></xstr>", > text: val1, num: val2) > > I spent some time looking at some Lua code this last week - I'm > considering unifying the function mechanism to take a > pair<dictionary_t, array_t> similar to a Lua table - This would let > you write: > > xstring_replace("<xstr id=3D'string'><marker id=3D'text'/> the number is > <marker id=3D'num'/></xstr>", > text: val1, num: val2) > > And would allow for a single API to plug-in functions. Thoughts? > > Sean > > On Feb 11, 2006, at 12:15 AM, Ralph Thomas wrote: > > > Hi ASL, > > > > I'm trying to write a function to do xstring substitution, which > > should work something like this: > > > > sheet { > > interface: > > val1 : "hello world, " ; > > val2: 17 ; > > output: > > string <=3D=3D xstring_sub( "<xstring id=3D'text'/> the number is <xs= tring > > id=3D'num'/>", [{ name: "text", value: @val1 }, { name: "num", value: > > @val2 }] ); > > }; > > > > and have @string be "hello world, the number is 17". I can easily get > > the values that I need from the sheet, but how can I create an > > xstring_context_t that contains these values? Is there a way to put a > > value_t straight in there? > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. Do you grep through > > log files > > for problems? Stop! Download the new AJAX search engine that makes > > searching your log files as easy as surfing the web. DOWNLOAD > > SPLUNK! > > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=103432&bid#0486&dat=12164= 2 > > _______________________________________________ > > Adobe-source-devel mailing list > > Ado...@li... > > https://lists.sourceforge.net/lists/listinfo/adobe-source-devel > > |