effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Renaming of keywords and types

Open phischu opened this issue 1 year ago • 5 comments

I would like to see the following syntactic changes. They have to be discussed and rejected or approved.

  • rename type Boolean to Bit
  • rename keyword type to datatype
  • keep keyword type for type aliases
  • change syntax var x = 1; ... to var x := 1; ...
  • change syntax x = 1; ... to x := 1; ...
  • remove return statement
  • remove with statement
  • sequence constructors not with semicolons type B { True(); False() } but type B { case True() case False() }
  • create instances without keyword new like def x = State { def get() = 1 def set(y: Int) = () }
  • put the condition in while in curly braces while { cond } { body }

phischu avatar Oct 11 '23 06:10 phischu

Boolean to Bit

I fear this will confuse everybody. Almost all languages have booleans (or i2 ;) ). What about Bool?

type to datatype

I know that this is analogous to the length of the name interface. Effekt is already quite verbose to type in demos, what about data?

remove return statement

You don't have to use it. I just added it for demos to sometimes explicitly mark returns.

remove with statement

Ideally we redesign it, not drop it. In Shonan discussions it became visible that something like a with statement is essential for practical use.

sequence constructors

Again, this makes things more verbose (I know duality to the destructor site). I have to think about this one---not sure yet I like it.

create instances without keyword

I think this cannot work syntactically, we already have a lot of type-directed overloads. Now look at Empty {} -- is this a function call? Creating a new object? I would have a hard time disambiguating this. Maybe see it like this: data is syntactically biased towards construction, codata towards observation.

put the condition

This is another thing that will heavily confuse people. The only reason for doing this would be to move it to the stdlib:

def while { cond: =>  Bool } { prog: => Unit }: Unit = {
  def go(): Unit = if (cond()) { prog(); go() } else { () }
  go()
}

Actually, I forgot, did I add while(cond) { p1 } else { p2 } to the language? I meant to at some point.

b-studios avatar Oct 11 '23 07:10 b-studios

I want to add something to this list: Desugar resume() to resume(()). Alternatively, allow effect operations to have 0 return values.

serkm avatar Oct 16 '23 20:10 serkm

this is hopefully already addressed by #272

b-studios avatar Oct 16 '23 21:10 b-studios

Since we're talking about this IRL (cc @phischu @marzipankaiser):

  • rename keyword type to datatype

If we want to actually align interface and datatype, we could use data type (and then type can be left as a type alias :) )

[brought to you by the 🚲🏠 Effekt working group]

jiribenes avatar Nov 07 '23 15:11 jiribenes

Let's not take this pun too far. I'd like to pick keywords primarily for three reasons:

  • how easy they are to use (interface is not here here, too long)
  • how easy they are to explain (interface is perfect here)
  • how well they fit with other concepts and keywords

I definitely prefer data over type, datatype, or data type

b-studios avatar Nov 08 '23 08:11 b-studios