On Sun, 18 Sep 2016, Sven Schreiber wrote:
Am 18.09.2016 um 12:16 schrieb Riccardo (Jack) Lucchetti:
>
> * enable print to output expressions rather than simple variables
> (we alredy have eval for that though)
Yes, the issue print-vs.-eval has come up several times. In
principle "eval" should be made redundant by extending "print" to
become the union of what is now print and eval -- if I'm not
missing something, that is.
First off, the genetic difference between "print" and "eval" is
historical: "print" is an ancient command (originally used only for
printing series), while "eval" is an offshoot of what was once our
"new genr" apparatus (a proper recursive descent parser). "New genr"
has been around for many years now but it long postdates "print". If
these respective histories were the only real difference between the
two commands, there would surely be a case for merging them.
However, I don't think history is the only relevant difference.
While some usages of the two are pretty much equivalent, each
command offers generality in its own specific dimension.
In the case of "print" you can print the values of multiple objects:
you can put the names of as many objects as you like (simply
space-separated) on a "print" command line.
In the case of "eval" you are allowed just one expression on the
command line, but it does not have to be the name of an existing
object; it can be as complex as you like, as in
eval (y - X*inv(X'X)*X'y)'(y - X*inv(X'X)*X'y)
(not a smart usage, but never mind).
It seems to me these extensions cannot be combined. An
argument-array which simply lists a bunch of objects of arbitrary
type is fine for "print" but is not something that's going to work
with "eval", which is inherently looking for something that makes
syntactical sense -- something that would be OK on the right-hand
side of an assignment, except that you don't care to assign the
result to anything.
Even in very basic usage, there's a difference which I sometimes
find useful (in the sense of having a reason to prefer one or the
other command, depending on the context): "eval" simply dumps the
result, while "print" may add some extra information (e.g. in the
matrix case, where the name and dimensions of the matrix are
displayed). Sometimes I'd like to see the extra info, sometimes not.
Allin