johnynek / bosatsu

A python-ish pure and total functional programming language
Apache License 2.0
224 stars 11 forks source link

syntax nits #828

Open johnynek opened 2 years ago

johnynek commented 2 years ago

This is a list of syntax issues that seem irregular or confusing and should be possibly changed.

johnynek commented 2 years ago

One thing I've noticed wrt to user defined types, we define them with parens:

struct Foo(a: Int)

and can treat them as functions or names:

f = Foo(1)
f = Foo { a: 1 }

The function application style is actually also auto currying (like all functions).

An alternate approach would be to only use the named style:

struct Foo { a: Int }

f = Foo { a: 1 }

this regularizes the syntax a bit but makes the currying style more verbose:

# original
struct Foo(a: Int, b: Int)
make_with_a1 = Foo(1)
# this is now Foo(1, 2)
f = make_with_a1(2)

# in the proposal:
struct Foo { a: Int, b: Int }
make_with_a1 = \b -> Foo { a: Int, b }
f = make_with_a1(2)
johnynek commented 1 year ago

now that currying has been removed, this makes more sense. #1026