On 2020-06-18 13:47, Nils Bruin wrote:
> 
> To compare: magma has function-application-on-the right in the notation x@f 
> and map composition f*g (for right action). So with

Off-topic:

For some programming-language design trivia, the explicit syntax for
function application on the right has a lot going for it. Using
parentheses has well-known problems, particularly to anyone who has
taught the chain rule. They also make it awkward to curry functions of
multiple arguments. If I want to write the function that adds three to
its argument on a chalkboard, I have to make up some junk like
plus(3,--) with a dash or dot in the hole where the argument goes. In
python, I have to use e.g. lambda x: plus(3,x).

Many functional languages solve that problem by using spaces for
function application, and by treating all functions as functions of one
argument (that return other functions). So you would write

  plus

for the function that takes an argument and returns (a function that
takes another argument and adds the first argument to it). Thus

  plus 3

is the function that adds three to its argument, and

  plus 3 4 = (plus 3) 4

is probably 7. Of course, that has problems too, not the least of which
is having the most important operation in the language be invisible and
generally unparseable. If I want to make a higher level function, how do
I apply some other function to a space? Is your language going to parse
"   " as function application applied to function application? Nah. An
explicit visible application syntax solves those problems and others. To
keep the same example,

  3@plus

would be what we want, and

  4@3@plus = 4@(3@plus) = 7

Finally, working left-to-right eliminates all of the annoying problems
that arise when you do something to (f `compose` g) and everything
flips. It's also just nicer to read, because when you see

  ((x@foo)@bar)@baz

you can start reading, "I take x, and give it to foo; then I take the
result and feed it to bar..." Whereas with baz(bar(foo(x))) you have to
get all the way to the end before you can reverse engineer what's about
to happen. There is also usually shortcut for function composition
mentioned, so that the parentheses above can be avoided above, like

  x@foo;bar;baz

The paper "A useful lambda-notation" by Fairouz Kamareddine and Rob
Nederpelt was once recommended to me on this same topic. Curiously
(after I spent 2 months figuring out how to read it), the "item
notation" they devise for the lambda calculus is basically "@".

But @ is matrix multiplication in python, so we're screwed there =)

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/976f2cac-5c96-40db-d159-30d2e192ed74%40orlitzky.com.

Reply via email to