3 ms·
> why not a Go implementation in Nim via cross-compilation? Nim's macros have one limitation that prevents an accurate implementation of another syntax: they c
by stefantalpalaru 11y ago
> why not a Go implementation in Nim via cross-compilation?
Nim's macros have one limitation that prevents an accurate implementation of another syntax: they can't fully modify the existing syntax.
See how I had to use "scase" inside "select" blocks because the existing "case" keyword insists on having "of" after it. So Nim's semantics put some limits on the amount of hijacking one can inflict on it through macros.
- stcredzero 11y agoIf you front compilation with Go's parser, you could generate bog-standard Nim code from the AST.
- stefantalpalaru 11y agoYou can, but you'd be limiting yourself to pure Go. I'd rather have Go with Nim's generics, transpilation to C, macros, compile time computation, etc.
- kodablah 11y agoI don't believe they should accept the full Golang syntax, just help with the import. E.g. macro goImport(path: string): stmt // TODO discard goImport("golang.org/x/crypto/nacl/box")