Open malisetti opened 5 years ago
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.
V already has https://vlang.io/docs.
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
Ah. We have been talking about writing an extensive compiler specification. I'll pin this issue.
These are different things. @mseshachalam refers to language spec, you refer to compiler spec.
@medvednikov Do you think it would be good idea to start on this ? I am interested in working on this.
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).
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.
Yeah, I think that would be great, @spy16
I've also created an RFC repo: https://github.com/vlang/rfcs
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
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?
I'd like to contribute a V to JavaScript compiler, it's better to have a relatively clear spec about the grammar
@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 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 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.
We will have a formal spec after 1.0.
And the language will barely change after 1.0, similar to Go.
The parser might be generated by a higher order function using BNF or PEG. See
See also this https://github.com/vlang/vls/issues/428 EBNF
grammar to be viewed at https://www.bottlecaps.de/rr/ui
Something like https://golang.org/ref/spec