
Wait, if positional arguments are mandatory only, and keyword arguments (possibly optional) must always be specified first in function applications, you don’t need parentheses for fun apps, is that correct? Like some kind of htroF

How so?

add1 2
sub1 5
vs
add1 2 sub1 5

How do you distinguish them?

Function application would be a little more ‘eager’, so here both cases would be read as (add1 2) (sub1 5)

Sounds like LOGO

Oh, because you can compute arity beforehand? Wouldn’t that need a type system?

Arity is fixed (no variadic operator, say)

so when you encounter add1
you can query the arity. You don’t need a type system

*Arity for positional arguments is fixed You can have as many optional kw args as you want

variadic operators will need parenthesis for application

OK, consider:
id id id id
Should it be
((id id) (id id))
or
(((id id) id) id)

left associative

But what if I want the other behavior?

you don’t

:smile:

Use parens then

Ah, so this is ML style.

with keywords :slightly_smiling_face:

That’s the trick: if you put them first, you can still omit the parentheses

(most of the time)

So ((id id) (id id))
would be written id id (id id)

because there would be no such thing is printing a procedure (unless quoted somehow)

There’s no way you can convince me that id id (id id)
isn’t read as (id id (id id))
:disappointed:

It’s too wired already in my brain

This is like a totally new way to read code

that’s fine, it would be for young people :stuck_out_tongue:

It’s too context sensitive. Human (well, at least me) can’t compute arity of functions in their head.

But more seriously, I was wondering if something like that could alleviate scheme in the terminal/command line.

uh? When you type a fun app, you need to specify the arguments, so of course you do

That is true for a writer. Not true for a reader who tries to understand code.

And code is mostly for reading

hmm

That would be mostly for the command line as I mentioned, where parentheses are annoying because you need to count them in most settings

Pop quiz: tell me how the following real world code should be read?
compose3 number->string add1 string->number my-input
vs
compose2 trace map add1 xs

If evaluation is too eager, the first line is an error, and you may want something like (à la kind of lisp I guess): compose3 #'number->string #'add1 #'string->number my-input
to mean ((compose3 number->string add1 string->number) my-input)

If you rewrite the second example with this it should be obvious :slightly_smiling_face:

Nooooo
But for entertainment, sure, here’s the result
compose2 #'trace #'map #'add1 xs

If compose2 takes 2 arguments, that doesn’t look right to me

((compose2 trace map) add1 xs)

That would mean : ((compose2 trace map) #'add1 xs)

ah yeah, actually that works :slightly_smiling_face:

Now, tell me, how many % of your brain did you use to read that code? :stuck_out_tongue:

That needs a little training probably, and again it’s for writing ephemeral code in the terminal

so I’m not going to force anyone to read it