That said, having a calculation language as part of the system doesn't
hurt, and warrants discussion. The reason the existing language is
half-baked is that I am not sure it is the right way to go, it was my
first attempt.
Different people have different needs, and there are various ways
treesheets could be made more programmable:
- the current visual formulas
- excel style formulas
- a macro system
- a scripting language plugin (e.g. Lua)
I certainly don't want to do all of them, i.e. I want to keep things
elegant and simple.
I do like your suggestion on using cell contents as variable lookups.
The way I understand it, it could look something like this
(indentation -> tree structure):
sales
1
2
3
sum(sales)
6
i.e. any unknown names in a formula cause the system to search for a
cell with that name, and then use the children of that cell as the
value to operate on. The result of the formula evaluation would then
be presented as the child of the formula cell. This would also have
the formula always visible, unlike excel. Some will prefer this,
others will not.
Formula cells could be styled in a different way, they could require
the '=' prefix, or require marking the cell as being a formula
manually, like the current language.
As to reusing an existing language for this, you're telling that to
someone who probably holds a world record for inventing languages, So
that may be a tall order ;)
I don't think this language should have a sequential evaluation order,
it is more natural to let the system resolve dependencies and ensure
the right order automatically. The question is how to refer to formula
cells, this could either be done by making a label the parent of a
formula, or allow label: to prefix a formula, for example.
Wouter
The way Clyde summarized it is definitely true.That said, having a calculation language as part of the system doesn't
hurt, and warrants discussion. The reason the existing language is
half-baked is that I am not sure it is the right way to go, it was my
first attempt.Different people have different needs, and there are various ways
treesheets could be made more programmable:- the current visual formulas
- excel style formulas
- a macro system
- a scripting language plugin (e.g. Lua)I certainly don't want to do all of them, i.e. I want to keep things
elegant and simple.
That is certainly a very universal solution, as it allows you to plug
in any external tool, written in any language. But it is of course
also more heavyweight, since the external tool has to parse and
generate XML. Compare with a builtin scripting language, that can
operate on data directly.
This has consequences as to who it is for: having to write a separate
program that involves XML parsing is a barrier to entry that most
"users" won't be able to overcome. A builtin language is a bit
friendlier, and a formula language that lives inside cells is
friendlier still.
> That means allowing the user to mark the meaning of particular cells in ways
> that the third-party program understands. You could do it just with tags. To
> your existing XML output format, add an attribute that marks the cell as
> tagged. The transforming program responds to the tag names and interprets
> their grid accordingly, possibly also having a default action for untagged
> cells or unrecognised styles.
I am not sure if that is even necessary: the external program can
interpret the cell text as it pleases.
> However, Treesheets do not /have/ to use text to distinguish between cell
> meanings. T hey can do it much better by varying the presentation style. I
> got this idea from the ColorForth programming language - instead of colour
> changes highlighting syntax that is expressed in some other way, it is the
> assigned colour itself that determines how the text is interpreted. Although
> this would entail more radical changes to Treesheets, I really would like to
> see something akin the WP stylesheets. Instead of changing the style of a
> cell directly, you would create a named style that could then be applied to
> cells with one click. Editing the style would alter the presentation of all
> the cells to which that style was applied.
> The style name would of course be chosen by the user to reflect the
> semantics of the cell, and would be passed to the transforming program. I'm
That would certainly be the most flexible, but not simple enough for
my tastes. The power of TreeSheets is about being able to handle
unstructured data; adding "schemas" back in makes it less flexible.
> beginning to think that the export format might usefully be JSON, since it
> is less verbose than XML. Many simple unstyled cells would appear as
> strings, numbers or nested arrays, while styles would become the names of
> name:value pairs.
agreed, yes.
> Such external programs could be be written by third parties to provide many
> more functions than a calculator. Parsing JSON is well understood, and the
> result could be in any format, for use by any program.
Wouter
Don't worry, I will not allow TreeSheets to become bulky! Whatever
scriptability I may add will not affect loading time, memory usage and
such.
There is a bit of text at the end of the tutorial file that explains
more about the language (in the Advanced Operations section), and I
have made it a bit clearer how to mark things. This file will be in
the new release, which I am about to upload a release-candidate for
within the hour, so check that.
It is not much of a language, per se. It can do simple arithmetic and
sums, which covers 90% of how people use excel, but not much else.
Wouter
> --
> You received this message because you are subscribed to the Google Groups "TreeSheets" group.
> To post to this group, send email to trees...@googlegroups.com.
> To unsubscribe from this group, send email to treesheets+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/treesheets?hl=en.
>
>
If you've never seen it, I am curious what you think of it :)
I should maybe change Help -> Tutorial to point to that file instead
of the html?
Wouter
> As to reusing an existing language for this, you're telling that to
> someone who probably holds a world record for inventing languages, So
> that may be a tall order ;)
>
> I don't think this language should have a sequential evaluation order,
> it is more natural to let the system resolve dependencies and ensure
> the right order automatically. The question is how to refer to formula
> cells, this could either be done by making a label the parent of a
> formula, or allow label: to prefix a formula, for example.
I've been playing around with this for some time, and come up with these rules:
1 Run operates on a selection, not the whole sheet.
2 When Run, a formula cell is replaced with its value. Other cells
in the selection are returned unchanged
3 Therefore, a common technique will be to Paste and Run a selection.
4 When a cell is Run, its grid cells (if any) are Run first,
sequentially, in column-first order.
5 All formula are in Reverse Polish Notation (like a HP calculator)
6 Formula arguments may be single values or arrays (grids).
7 As in APL, arrays are normally treated element-by-element,
though there may be operators for reduction, and matrix or all-pairs
8 If an argument is not stated for an operator, the cell grid is used.
8 If the grid is absent or already used, use a copy of the
contents of the most recent unused Run cell
9 By rule 2, if a cell formula takes its grid as an argument then
the grid is no longer available or displayed.
10 The operator -> takes one argument and assigns it to a variable.
Variables are scoped to the grid in which they are first used.
A variable is roughly the same as an absolute spreadsheet reference.
In addition, we need operators to do relative referencing, by indexing
back into the grids already run.
In the example below - a basic spreadsheet exercise - " 2 r " means
"the cell 2 rows up", and "1 c" "1 column back"
Loan Payment Chart
Rate of interest
100 / -> roi
Payment
-> pay
Debt 1 c payoff -
Interest roi * roi *
Due + pay min + pay min
Debt paid 2 r - 2 r -
-> payoff -> payoff
To use this, paste a copy of the first two columns, enter values for
Rate of Interest, Payment and Debt, say 5, 500, 2,000
Run it, and the result should look like this:
Loan Payment Chart
Rate of interest 5
Payment 500
Debt 2,000
Interest 100
Due 500
Debt paid 400
Now paste and run the third column to the right as many times as
needed to reveal the bitter truth!
Unlike a spreadsheet, any or all of the parameters could be replaced
by a grid, to display several possible scenarios simultaneously.
Note how in this case each formula cell implicitly takes an argument
from the line above. The lines with -> do not return anything, and so
are blank in the result.
> I've been playing around with this for some time, and come up with these rules:
>
> 1 Run operates on a selection, not the whole sheet.
> 2 When Run, a formula cell is replaced with its value. Other cells
> in the selection are returned unchanged
> 3 Therefore, a common technique will be to Paste and Run a selection.
Sorry, but I do not like this one bit. It is very inconvenient to have
to copy-paste-select-run, when in most systems you can just run. I
also should be able to run it multiple times without "losing" my
formulas.
The formulas need to stay in place. Either they are hidden behind the
data like excel (which I am not a fan of), or they are always visible
and their child is the result computed, or they are folded away or
something.
> 4 When a cell is Run, its grid cells (if any) are Run first,
> sequentially, in column-first order.
>
> 5 All formula are in Reverse Polish Notation (like a HP calculator)
Why would that be... I have developed several RPN (Forth) style
languages myself, and really love their elegance, but the vast
majority of humans have trouble reading it. I'd like it to be end user
friendly.
Wouter