The Go+ programming language is designed for engineering, STEM education, and data science. Our vision is to enable everyone to become a builder of the digital world.
Currently, when converting Go+ code or Go code to gop_autogen.go, we only preserve the associated documentation of the Node, but the comments are ignored.
For example:
const Pi = 3.14
var version = "1.0"
// comment one
func MulInt(a, b int) int {
// comment two
return a * b
}
// comment three
func MulFloat(a, b float64) float64 {
return a * b
}
// comment four
func Add = (
// comment five
func(a int, b int) int {
// comment six
return a+b
}
func(a float64, b float64) float64 {
return a+b
}
)
func Mul = (
// comment seven
MulInt
// comment eight
MulFloat
)
type M struct {
Info string
}
type T struct {
X int
Y int
}
func (t *T) Info() string {
return sprintf("%v-%v", t.X, t.Y)
}
func onStart(fn func(int) int) {
// comment nine
n := fn(100)
println n
}
println(version)
// comment ten
onStart x => x*x
onStart x => {
// comment eleven
return x*x
}
we got:
// Code generated by gop (Go+); DO NOT EDIT.
package main
import "fmt"
const _ = true
const Pi = 3.14
const Gopo_Mul = "MulInt,MulFloat"
type M struct {
Info string
}
type T struct {
X int
Y int
}
//line examples/002/002.gop:16:1
// comment four
func Add__0(a int, b int) int {
//line examples/002/002.gop:21:1
return a + b
}
//line examples/002/002.gop:16:1
// comment four
func Add__1(a float64, b float64) float64 {
//line examples/002/002.gop:24:1
return a + b
}
//line examples/002/002.gop:5:1
// comment one
func MulInt(a int, b int) int {
//line examples/002/002.gop:8:1
return a * b
}
//line examples/002/002.gop:11:1
// comment three
func MulFloat(a float64, b float64) float64 {
//line examples/002/002.gop:13:1
return a * b
}
var version = "1.0"
//line examples/002/002.gop:44:1
func (t *T) Info() string {
//line examples/002/002.gop:45:1
return fmt.Sprintf("%v-%v", t.X, t.Y)
}
//line examples/002/002.gop:48:1
func onStart(fn func(int) int) {
//line examples/002/002.gop:50:1
n := fn(100)
//line examples/002/002.gop:51:1
fmt.Println(n)
}
//line examples/002/002.gop:54
func main() {
//line examples/002/002.gop:54:1
fmt.Println(version)
//line examples/002/002.gop:57:1
onStart(func(x int) int {
//line examples/002/002.gop:57:1
return x * x
})
//line examples/002/002.gop:58:1
onStart(func(x int) int {
//line examples/002/002.gop:60:1
return x * x
})
}
From a completeness perspective, I am thinking it would be better to keep all original comments as much as possible.
Background
Considering that the gop_autogen.go file is intended to be pushed into the code repository, I am currently exploring ways to ensure it adheres to the standard Go coding style.
gop_autogen.go is not intended for reading. It primarily exists to fulfill interfaces with the Go ecosystem toolchain, so reading its code is not recommended.
Proposal
Currently, when converting Go+ code or Go code to gop_autogen.go, we only preserve the associated documentation of the Node, but the comments are ignored.
For example:
we got:
From a completeness perspective, I am thinking it would be better to keep all original comments as much as possible.
Background
Considering that the gop_autogen.go file is intended to be pushed into the code repository, I am currently exploring ways to ensure it adheres to the standard Go coding style.
Workarounds
node