From: Sean P. <sp...@ad...> - 2009-05-08 03:05:35
|
On May 7, 2009, at 10:42 AM, Robert Dailey wrote: > Thanks for your detailed responses. I really appreciate the help. > I've provided some follow-up questions below: > > Correct - constant is immutable. Input cells are set from outside - > input cells are used to initialize (or reinitialize) a sheet with > data from the application. A typical example is a command that > resizes a document might be seeded with the original document size > so you could constrain proportions. Input cells can be set using > sheet_t::set (either variant) <http://stlab.adobe.com/classadobe_1_1sheet__t.html#3cd494209eea1aa2b777c8da1585ba0d > >. > > So if I try to call sheet_t::get() on an Input Cell, I will get an > exception or some other type of failure? According to the > documentation, sheet_t::get() can be used on an Output Cell, but > this does not cause the logic of the output cell to be updated. > sheet_t::update() must be called before calling sheet_t:get() on an > Output Cell in order to get its most accurate and up-to-date value, > correct? Additionally, Logic Cells cannot have set() or get() called > on them, correct? Their scope is limited to the script file in > question? sheet_t::get() was private until recently - it was made public as part of an effort to remove the dependency on the VM from the sheet_t. Soon you will be able to use sheet_t without the parser by providing function objects to define cells. Currently get() is called to do variable lookup by the VM during update(). If you call it after an update you will get the last cached value for the cell. Generally, sheet_t is a push model - you monitor values, you don't get them. If you try to call set() on an output, logic, or constant cell you will get an exception. If you try to monitor and input, logic, or constant cell you will get an exception. > > I'm just trying to make sure I have a grip on the concepts. > > Colon is used to denote an initializer. Normally an initializer is > only executed once (there is some support to reinitialize a sheet > that will cause some initializers to be evaluated again). The "<==" > is used to denote a defining expression. These are rules which are > evaluated anytime the sheet is updated. > > So if I have something like this: > > constant: > my_cell : 0 <== 4+5 Then you get a syntax error - constant and input cells can only have an initializer. It is only interface cells which play a duel role that can have both an initializer and a defining expression. > > Both a logic cell and an output cell have logical state (they are > like equation cells in a spreadsheet) so they have no initializer. > There value is always the value of the expression defining them. An > interface cell is the one cell type that has state _and_ a defining > expression (it can either be a contributing or derived depending on > the state of the sheet). > interface_cell : constant_cell <== input_cell; > > So if I do this: > > logic: > my_logic_cell : 0 <== 5+5 > > This is malformed? Will this cause an error during parsing? What > would this behavior mean if it is not erroneous? This is a syntax error. > How are logic cells different from a regular cell delimited by a > colon? Furthermore, I am confused about 'logic' and 'output' as well > now. > > logic cells and ouput are just like equation cells in a spreadsheet > (where constant cells and input cells are like value cells in a > spreadsheet) - the major difference between an output cell and a > logic cell is that the output cell value can be monitored from > outside the sheet using sheet_t::monitor_value <http://stlab.adobe.com/classadobe_1_1sheet__t.html#48ec8465134b96deaee81c69be9084a2 > >. > > But one can also use sheet_t::get() instead of monitoring the value, > correct? So since output cells can only be mutated by the expression > they are bound to, this means monitor_value() can only detect a > change when that "equation" is calculated with a different result. > Correct? As mentioned above - you normally wouldn't use get() - you would monitor the cell. The monitor function is only called when the value of the cell is changed during an update. > > Keep the questions coming... > > Assuming I'm finally getting this, I think I've come a long way. > This is actually turning out to sound very intuitive! Thank you for > bearing with me through my questions. Let me know if I'm still > misunderstanding some things. > > My goal is to try to make an open source graphical tool for Adam & > Eve in the future. Right now it all seems to be hand-written, but it > would be nice to have a drag & drop approach to creating a GUI with > ASL. My first step, however, is to try to fully understand how to > use ASL in practice. Nice - we have an internal tool for building these graphically - unfortunately we aren't able to open source it. I'm sure Foster can chime in with many suggestions. I've started working on yet another rewrite of sheet_t using the Boost Graph Library - this should make it fairly trivial to visualize a sheet_t with GraphViz which I think would really help with debugging sheets. I always draw them out by hand currently before coding them. See slide 66 here for my set of "standard" symbols. <http://stlab.adobe.com/wiki/images/0/00/2008_04_03_accu.pdf > Sean |