laurent.orseau
2021-2-6 19:47:02

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


sorawee
2021-2-6 20:27:34

How so?


sorawee
2021-2-6 20:27:58

add1 2 sub1 5 vs

add1 2 sub1 5


sorawee
2021-2-6 20:28:13

How do you distinguish them?


laurent.orseau
2021-2-6 20:29:47

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


samdphillips
2021-2-6 20:30:41

Sounds like LOGO


sorawee
2021-2-6 20:30:57

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


laurent.orseau
2021-2-6 20:31:40

Arity is fixed (no variadic operator, say)


laurent.orseau
2021-2-6 20:31:57

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


laurent.orseau
2021-2-6 20:32:26

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


laurent.orseau
2021-2-6 20:32:58

variadic operators will need parenthesis for application


sorawee
2021-2-6 20:33:12

OK, consider:

id id id id Should it be

((id id) (id id)) or

(((id id) id) id)


laurent.orseau
2021-2-6 20:33:35

left associative


sorawee
2021-2-6 20:33:45

But what if I want the other behavior?


laurent.orseau
2021-2-6 20:33:50

you don’t


laurent.orseau
2021-2-6 20:33:52

:smile:


samdphillips
2021-2-6 20:34:02

Use parens then


sorawee
2021-2-6 20:34:47

Ah, so this is ML style.


laurent.orseau
2021-2-6 20:35:05

with keywords :slightly_smiling_face:


laurent.orseau
2021-2-6 20:35:42

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


laurent.orseau
2021-2-6 20:35:50

(most of the time)


laurent.orseau
2021-2-6 20:36:53

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


laurent.orseau
2021-2-6 20:37:31

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


sorawee
2021-2-6 20:38:15

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


sorawee
2021-2-6 20:38:39

It’s too wired already in my brain


sorawee
2021-2-6 20:38:57

This is like a totally new way to read code


laurent.orseau
2021-2-6 20:39:16

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


sorawee
2021-2-6 20:39:51

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


laurent.orseau
2021-2-6 20:40:12

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


laurent.orseau
2021-2-6 20:40:51

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


sorawee
2021-2-6 20:41:45

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


sorawee
2021-2-6 20:41:54

And code is mostly for reading


laurent.orseau
2021-2-6 20:42:13

hmm


laurent.orseau
2021-2-6 20:43:00

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


sorawee
2021-2-6 20:52:36

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


laurent.orseau
2021-2-6 20:55:43

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)


laurent.orseau
2021-2-6 20:56:37

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


sorawee
2021-2-6 20:57:59

Nooooo

But for entertainment, sure, here’s the result

compose2 #'trace #'map #'add1 xs


laurent.orseau
2021-2-6 21:01:16

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


sorawee
2021-2-6 21:01:55

((compose2 trace map) add1 xs)


laurent.orseau
2021-2-6 21:01:56

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


laurent.orseau
2021-2-6 21:02:16

ah yeah, actually that works :slightly_smiling_face:


sorawee
2021-2-6 21:02:37

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


laurent.orseau
2021-2-6 21:03:29

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


laurent.orseau
2021-2-6 21:04:01

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