[Grace-core] How many method application brackets does one language need?

James Noble kjx at ecs.vuw.ac.nz
Mon Mar 7 19:31:08 PST 2016


> On 8/03/2016, at 14:41pm, Michael Homer <Michael.Homer at ecs.vuw.ac.nz> wrote:
> 
> For clarity, an example of both styles of call is:
>    list ( 1, 2, 3 )
>    list [ 1, 2, 3 ]

this is not a setup - but I can see Michael's point.

thinking about this (again) - it is a bit odd that (given overriding with arity) all of 

list
list (1)
list (1, 2)
list (1, 2, 3)
list (1, 2, 3, 4)
list (1, 2, 3, 4, 5)

are legal, and at least able to be defined as easily as 

if (_) then (_) 
if (_) then (_) else ()
if (_) then (_) elseif () then () else ()
if (_) then (_) elseif () then () elseif () then () else ()

if we get rid of [] brackets in BOTH indexing AND "iterables" then we could use [ ] for generics with *no* parsing issues whatsoever.

for the time being, minigrace could just special case the parser so writing list() or seq() does what [] does now.

Yes, people passing sequences would have to write:

myWindow.addWidgets (seq(
   title "Launch",
   text "Good Morning Mrs President", 
   button "OK" action { missiles.launch },
   button "Cancel" action { missiles.abort }
)) 

rather than 

myWindow.addWidgets [
   title "Launch",
   text "Good Morning Mrs President", 
   button "OK" action { missiles.launch },
   button "Cancel" action { missiles.abort }
]

but getting rid of BOTH indexing and "lineups" would really simplify this part of the language.
I have been sceptical of taking on overriding on arity but this would help convince me.

But going one step further: how much is it worse than writing e.g. 

list
list (1) 
list (1) and (2)
list (1) and (2) and (3) 
list (1) and (2) and (3) and (4)
list (1) and (2) and (3) and (5) and (5) 

or 

myWindow.addWidgets 
  (list (title "Launch") 
   and (text "Good Morning Mrs President") 
   and (button "OK" action { missiles.launch}) 
   and (button "Cancel" action { missiles.abort }) )


HMM: I can see the first one being clumsy, but the second looks... surprisingly fine.



Andrew might ask - what happens to "list.empty" - answer  - we just write "list".
what happens to "list.withAll"  - we just write listWithAll  or listFromAll or something.asList


unfortunately I think we should think about this again too

James


More information about the Grace-core mailing list