Michael2109 / cobalt

The Cobalt programming language
GNU Lesser General Public License v3.0
37 stars 10 forks source link

Write a language specification for the current parsers #371

Open Michael2109 opened 6 years ago

Michael2109 commented 6 years ago

These all need to be thoroughly expanded on. Each format the code can be in with examples. Possibly write what can/can't be done. Any ideas are welcome for if you would like to add anything from other languages. If you're unsure of anything then give me a message.

Michael2109 commented 6 years ago

I'm currently updating some of the wiki pages and it's making me think quite a bit about how the language is going to look.
Currently defining a method is like this.

exampleMethod : Int -> Int -> Int
exampleMethod a b = 
  a + b

This looks really nice but we need a method of adding modifiers.

public
exampleMethod : Int -> Int -> Int
exampleMethod a b = 
  a + b

Define it at the top.

public
  exampleMethod

exampleMethod : Int -> Int -> Int
exampleMethod a b = 
  a + b
public
  exampleMethod : Int -> Int -> Int

exampleMethod a b = 
  a + b
public
  exampleMethod : Int -> Int -> Int

exampleMethod a b = 
  a + b

I'm wondering if we can come up with something highly readable that doesn't require the user to type extra code. With this in mind it might be worth looking at Java/Scala (Or any others?) to see if their methods are more readable.

FilipJanitor commented 6 years ago

Regarding the language features - generics/templates might be useful and also some sort of implicit tuples - just like Go has for returning multiple values for functions.

On Tue, 27 Mar 2018, 02:03 Michael, notifications@github.com wrote:

I'm currently updating some of the wiki pages and it's making me think quite a bit about how the language is going to look. Currently defining a method is like this.

exampleMethod : Int -> Int -> Int exampleMethod a b = a + b

This looks really nice but we need a method of adding modifiers.

public exampleMethod : Int -> Int -> Int exampleMethod a b = a + b

Define it at the top.

public exampleMethod

exampleMethod : Int -> Int -> Int exampleMethod a b = a + b

public exampleMethod : Int -> Int -> Int

exampleMethod a b = a + b

Really it just seems messy. If we then include a main method for example you would then need this.

public exampleMethod : Int -> Int -> Int

static main: Array[String] -> void

exampleMethod a b = a + b

main args =

Do something

With this in mind it might be better to focus on a syntax more similar to Java/Scala (Or any others?) Or decide upon one of these options.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Michael2109/cobalt/issues/371#issuecomment-376351198, or mute the thread https://github.com/notifications/unsubscribe-auth/AO2aW6eX1g7cgnEiOOEjwCN-6cbb53olks5tiYHXgaJpZM4S6w-X .

FilipJanitor commented 6 years ago

I feel like this should be the number one priority at the moment. Spec would make writing tests way more simple(no need to reverse engineer and guess scala/like features) and also the work on the parser (and possible fixes) would be easier.

There is no need to make it pretty or formalised yet (that can be done later) but something that would outline and summarize the basic syntactic constructions and would clarify some terms used would help tremendously.

Michael2109 commented 6 years ago

I think one thing with this is deciding where to put proposals for ideas etc. We could have a separate doc containing all proposals and anything that gets in gets moved to the spec. Or add individual issues on here but I feel it would be better keeping them in one place we can all access.

Michael2109 commented 6 years ago

There is a lot to filter through for this. I'm not too sure which parsers are left to complete still. I thought all parsers were added to this and any new parsers are being added so it should cover everything (although some with little detail).