v icon indicating copy to clipboard operation
v copied to clipboard

Declare Language Specification

Open malisetti opened this issue 6 years ago • 19 comments

Something like https://golang.org/ref/spec

malisetti avatar Jun 20 '19 12:06 malisetti

This is important I think. Can help reduce ambiguity for any contributors. I'd like to help if you all think we should do this.

spy16 avatar Jun 25 '19 04:06 spy16

V already has https://vlang.io/docs.

LouCle avatar Jun 25 '19 04:06 LouCle

I was talking about more of a language spec. With technical description of grammar and implementation details. Docs section is more of a language usage documentation

spy16 avatar Jun 25 '19 04:06 spy16

Ah. We have been talking about writing an extensive compiler specification. I'll pin this issue.

LouCle avatar Jun 25 '19 04:06 LouCle

These are different things. @mseshachalam refers to language spec, you refer to compiler spec.

medvednikov avatar Jun 25 '19 09:06 medvednikov

@medvednikov Do you think it would be good idea to start on this ? I am interested in working on this.

spy16 avatar Jun 28 '19 06:06 spy16

It might be good to require new features to the compiler to come with spec docs. The existing features can be documented over time (0.2 seems too ambitious and no one's volunteered, plus some features are probably still in flux).

ntrel avatar Jun 28 '19 06:06 ntrel

Agreed about new compiler features to come with spec docs. With respect to existing ones, that was precisely the question. "starting" on it. Also, syntax-wise i think @medvednikov has already sort of finalized it. So, only implementation is under flux. My thought was that some type of formal documentation can help contributors to the compiler itself.

spy16 avatar Jun 28 '19 06:06 spy16

Yeah, I think that would be great, @spy16

I've also created an RFC repo: https://github.com/vlang/rfcs

medvednikov avatar Jun 28 '19 15:06 medvednikov

Any thoughts on how to get started here? Golang language specification is simple and straightforward. But what about the file format ? are you expecting it to be in markdown or something else? @medvednikov

spy16 avatar Jul 01 '19 05:07 spy16

Does it make sense to write a spec at this point already? It sounds like a lot of features and syntax are still being discussed.

Might make more sense to extract a specification after 1.0, so the language can grow and settle organically until then?

mindplay-dk avatar Jul 02 '19 14:07 mindplay-dk

I'd like to contribute a V to JavaScript compiler, it's better to have a relatively clear spec about the grammar

hsiaosiyuan0 avatar Aug 19 '19 13:08 hsiaosiyuan0

@mindplay-dk it is important to write a spec to test, via proof, fundamental properties of the language such as progress and preservation.

See chapter 6 on Type Safety: http://www.cs.cmu.edu/~rwh/pfpl/2nded.pdf

Here's another short writeup on StackOverflow: https://cs.stackexchange.com/a/58124

I would be very excited to see V formally specified, and have type safety properties proven on its specification. This would level up the language in maturity, and a more confident choice for engineers to use.

theonewolf avatar Sep 15 '20 19:09 theonewolf

@theonewolf I agree with all of that, as such - but the author seems to be taking more of an organic, exploratory approach, and having to maintain a spec as well basically double the workload.

At this stage, it might be better to have an executable spec, something like what PHP has? Basically a bunch of files saying "given this V input, program should give this output" - the benefit of an executable spec is, someone writing (say) a JS compiler for the V language, can easily run the exact same tests; so you're not just relying on written communication between the spec author and someone implementing the spec, but rather you have something formal and repeatable.

V lends itself well to this style of testing, being able to run a program from source-code directly. Many of the library features are already using that style of testing. The core language tests don't use this style of testing - so these are more like unit-tests, which, if you can run them and they pass, you're complying with the spec, but it's still an executable spec, and someone implementing an alternative compiler could definitely reuse this.

That said, a formal AST spec might make sense though. :-)

mindplay-dk avatar Sep 24 '20 08:09 mindplay-dk

@mindplay-dk I'm happy with any step in this direction. I really love the conciseness of V overall. Something feels good about that.

Let's not aim for perfect, or even good, when we just need good enough right now.

theonewolf avatar Sep 25 '20 17:09 theonewolf

We will have a formal spec after 1.0.

medvednikov avatar Sep 25 '20 21:09 medvednikov

And the language will barely change after 1.0, similar to Go.

medvednikov avatar Sep 25 '20 21:09 medvednikov

The parser might be generated by a higher order function using BNF or PEG. See

https://github.com/pointlander/peg

wenq1 avatar Jan 22 '23 04:01 wenq1

See also this https://github.com/vlang/vls/issues/428 EBNF grammar to be viewed at https://www.bottlecaps.de/rr/ui

mingodad avatar Feb 21 '23 09:02 mingodad