A cell's raw input is either a plain literal or a formula. The one rule that separates them is a leading equals sign. Today you classify a cell's input so the engine knows which cells it will have to compute later.
Classify a cell's string input as a number, text, or boolean literal, or as a formula when it starts with "=".
A real spreadsheet does not ask which kind of thing you are typing - it infers it.
Type 5 and you get a number; type hello and you get text; type =A1+1 and you
get a formula. The single rule that separates a formula from a literal is the
leading =. Everything else is a literal, and we classify literals by trying the
most specific interpretation first: does it parse as a number? is it exactly TRUE
or FALSE? otherwise it is text.
The important design choice today is that a formula cell stores its raw text and
is marked as a formula, but does not compute a value yet - its value stays
Empty. We have no parser or evaluator, so there is nothing to compute with. What
matters is that the sheet can now answer “is this cell a formula, and if so what is
its text” - the two questions the whole calculation engine is built to answer. The
next chapter turns that stored formula text into something we can evaluate.
// a cell now remembers its raw text and whether it is a formulafunc (s *Sheet) SetCell(a, in string) {if strings.HasPrefix(in, "=") {// store raw text; mark formula; value is Empty for nowreturn}if n, err := strconv.ParseFloat(in, 64); err == nil { /* Number */ }// "TRUE"/"FALSE" -> Bool; otherwise Text}