On Thu, 13 Apr 2017, Sven Schreiber wrote:
Am 11.04.2017 um 20:44 schrieb Allin Cottrell:
>
> I'm therefore proposing to wait until this Friday for the release. If you
> can beat on the snapshot and report any problems before then that would be
> much appreciated.
I can't say I have used it a lot or especially intensively, but I noticed the
following, which probably isn't new. The example is a self-contained
one-liner:
n = 1 ? check() : 0
Since the check() function isn't defined, this is obviously invalid. However,
the error message doesn't say "check undefined", instead it says
"symbol '('
is invalid in this context".
(The background was that I misspelt a function name, and this error message
was misleading.)
OK, turns out it was easier than I feared to arrange for a better
error message there: it'll be in git shortly.
However, this example raises an issue worth noting. Some time ago
there was a request to handle an undefined term in the context of
ternary "?:". We can handle and do handle that case, but only if the
term in question is unitary. For example
# check = 3
n = exists(check)? check : 0
will give n = 0, or n = 3 if the first line is uncommented. But the
following we cannot do:
# matrix check = {3}
n = exists(check)? check[1] : 0
(You'll get "The symbol 'check' is undefined", as in the
non-existent
function example.)
The point is that a straight 'word' can be marked as UNDEF when
parsing "?:", and that's OK so long as we don't end up trying to
evaluate the UNDEF term. But in cases like
check() # function call?
check(a,b,c) # function call?
check(-1) # lag?
check[1:3,] # matrix?
we need to keep parsing to figure out where the term in question ends,
and to do that we need to know what sort of symbol 'check' is. So for
the matrix case above one would have to use
if exists(check)
n = check[1]
else
n = 0
endif
so we can bypass the entire statement that depends on check's
existence.
Allin