[R] combining mathematical notation and value substitution

Thomas Lumley tlumley at u.washington.edu
Mon Jun 23 01:17:08 CEST 2003


On Sat, 21 Jun 2003, Faheem Mitha wrote:
>
> So multiplication is lexically valid in R even between logical
> expression and strings?
>

yes, in the sense that the lexer and parser won't choke when trying to
read the statement.

You could define a method for "*" that multiplied character strings (you
might have to work through defining Ops.character)

>
> Also, would it not be more accurate to describe an expression as a
> list of calls? Since, the [[ ]] applied to a list returns a component
> of that list, which in this case is apparently a call.
>

No, it would be less accurate (though arguably clearer). An expression is
not actually internally represented as a list of calls, just as
   list(quote(x*y), quote(a+b))
is represented as a list of calls, not an expression. Now, an expression
could have been just a list of calls (it works in LISP), but in fact it
isn't.


The problem in writing the R language definition is in trying to be both
precise and helpful (the paragraph you quoted is arguably neither, but
that's why it's a `draft').

The precise difference between an expression and a call is that an
expression is of mode "expression" and a call is of mode "call" (and a
list of calls is of mode "list"). This isn't very helpful, which is why
you get the handwaving about an expression being like a list of calls.


	-thomas




More information about the R-help mailing list