From: rbe@yrloc.ipsa.reuter.COM (Robert Bernecky)
Subject: Re: Goals, Cost, and Flexibility (was Re: "Training" of programmers)
Reply-To: rbe@yrloc.ipsa.reuter.COM (Robert Bernecky)
Organization: Snake Island Research Inc, Toronto
Date: Tue, 6 Oct 92 15:38:07 GMT

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:
>>>This is one of the problems with the current HLLs, the inability to use
>>>"mathematical" type notation.  I admit that I have not used these aspects
>>>of C enough to have the syntax right.
>>
>>I argue just the opposite.  One of the _advantages_ of current HLLs is the
>>inability to use "mathematical" type notation.  Mathematical notation is
>>ambiguous and highly dependent on context.  Current HLLs don't have this
> ^^^^^^^^^ ?????????
>>problem.  Furthermore, we don't want to introduce ambiguity and bizzare
>>context into HLLs.
>
>   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.

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.

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

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

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





Robert Bernecky      rbe@yrloc.ipsa.reuter.com  bernecky@itrchq.itrc.on.ca 
Snake Island Research Inc  (416) 368-6944   FAX: (416) 360-4694 
18 Fifth Street, Ward's Island
Toronto, Ontario M5J 2B9 
Canada
Newsgroups: comp.arch