bosatsu icon indicating copy to clipboard operation
bosatsu copied to clipboard

syntax nits

Open johnynek opened this issue 2 years ago • 2 comments

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

johnynek avatar Dec 28 '21 20:12 johnynek

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 avatar Dec 28 '21 20:12 johnynek

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

johnynek avatar Sep 10 '23 02:09 johnynek