From: hrubin@pop.stat.purdue.edu (Herman Rubin)
Newsgroups: comp.arch,comp.lang.misc
Subject: Re: Goals, Cost, and Flexibility (was Re: "Training" of programmers)
Date: 8 Oct 92 13:20:11 GMT
Organization: Purdue University Statistics Department

In article <1992Oct6.153807.20816@yrloc.ipsa.reuter.COM> rbe@yrloc.ipsa.reuter.COM (Robert Bernecky) writes:
>In article <1992Oct5.074115.277@newsroom.bsc.no> izahi@bsc.no (Raul Izahi Lopez Hernandez) writes:
>>In article <1992Sep29.232852.22456@CS.ORST.EDU> crowl@jade.CS.ORST.EDU (Lawrence Crowl) writes:

			.......................

>>   Can you show me how Mathematical notation can be ambiguous and highly
>>dependent on context?
>>   As far as I know anybody with a good high school training knows what
>>to do when she sees this:

>>   n=10
>>         n
>>	----
>>        \
>>         \
>>   A=    /    i*i
>>        /
>>        ---
>>       i=1
>>   What would you like to use? Flow diagrams? LISP? BASIC?

>The problem with the sigma notation and its friends, aside from the fact
>that they take a LOT of space to write in news articles... is that
>there is NO consistency or generality to them.

There are better ways to get the sigma notation into code; easier than
in news articles.  Of course, we need a character set of thousands of
characters, not just the 94 + blank which ASCII allows.  The time for
that stopgap is OVER.

>Consider the set of operators (in the sense of things which take 
>functions as arguments) which stick a function f among the elements
>of a list, and evaluate it (we ignore arrays for the nonce):

>In math, I have seen:
>   sigma for f =. +
>   pi    for f=.  *
>   big ^ for f=.  ^
>   big inverted ^ for f= inverted caret
>   MIN   for f=. <.  (minimum)
>   MAX   for f=. >.  (Maximum)

>Other functions are cobbled together with pages of explanation as to what
>the thing means (a) today (b) on this page. Or, with NO pages of
>explanation, and merely a terse comment, leaving you to guess what the
>author REALLY meant.

The mathematical notation is fairly standard, and MAX and MIN are even used
in Fortran I.  On the other hand, the usage of <. for minimum and >. for
maximum, which seems to be the usage Mr. Bernecky intends, in an APL-like
CONVENTION, known to nobody else, including programmers in most of the 
HLLs around.

>APL and J, on the other hand, formalize the idea of function insertion
>with the adverbs called reduction and insertion, respectively.

>F/x in J works as follows:
>   x[0] F x[1] F x[2] ... F [n-1]

>FOR ANY F! Totally strict semantics make it obvious what's going on to
>the reader, and also make it jimdandy easy to compile efficiently.
>So, for the above, we have:
>   +/x       NB.  Summation
>   */x       NB.  Multiply array elements together.
>   <./       NB.  Minimum element
>   >./       NB.  Maximum element
>   +./       NB.  Or over all elements
>   *./       NB.  And over all elements
>  foo/       NB.  Foo over all elements

This assumes that F/x does not have some other meaning.  This does not
happen often, but I can think of cases where it does happen.  So some other
symbolism is needed.  That does not mean that it is a bad idea, and after
sigma and pi were used, the idea of using a big letter for the corresponding
operation on an indexed family got into use.  We could change sigma to big +,
but a big multiplication symbol would get confused with the corresponding
symbol for Cartesian product.  Mathematics definitely has operators highly
overloaded, and the programming languages kept at least some of this.

>You can write your own, or use ANY extant function with precisely identical
>semantics. You can get alternating sum by:
>   -/x
>and alternating product by:  %/x

This one requires that you start from the right, a somewhat abnormal way
to define repeated operations, but not unique.  Remember that mathematics
also uses the same symbolism for infinite, and sometimes even uncountable,
indesed families.  Sum, product, maximum, minimum, or, and, xor, and many
others do not depend on linear ordering, and I do criticize those who
introduce sigma and pi by using consecutive elements of a sequence instead
of the general notion using commutativity and associativity.  Of course,
sometimes, espectially for infinitary operations, taking the limit for a
linear sequence is essential.


>Easy to teach to children, easy to remember, AND easy to typeset.
>No scaring people away with Greek or My Very Own Jargon.

I suspect that Polish notation, or reverse Polish, would also be easy
to teach to children and easy to remember.  Much more will be easy to
typeset when we finally discard ASCII, and this is on the horizon.  And
as far as jargon, four of the eight you have indicated above use jargon
which is not even close to HLL standard; from this point of view, there
are even major differences between Fortran and C.
-- 
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
Phone: (317)494-6054
hrubin@pop.stat.purdue.edu (Internet, bitnet)  
{purdue,pur-ee}!pop.stat!hrubin(UUCP)