Andy Balholm <andybalh...@gmail.com>: > A good translation from C to Go needs to look as much like the original, > un-preprocessed C source as possible. But a powerful translation tool will > probably need to preprocess, parse, and typecheck the code, while keeping > track of the source location that everything corresponds to—and then use that > information to guide the translation.
Perry and I have two different target languages in mind. Perry's target language is basically a repaired C - type-safe, almost upward-compatible. He and I have the same strategic goal - draining the swamp of old, leaky C code - we're just betting on slightly different ways to do it. We intend to cooperate as much as possible. But for both of them our intended strategy is *not* to preprocess. Instead, we're willing to accept that some abuses of the preprocessor need to be punted to a human, but treat other uses as part of the parse tree. For example if you have a set of #defines each of which expands to a syntactically well-formed C expression. it seems clear to us that the right thing is to recognize this and map them to const and func declrations, checking for and throwing an error on capture of any identifier that isn't a defined global. We're willing to throw an error on that, or on syntactically ill-formed macro expansion because we're not aiming for a completely perfect mechanized trannlation. We know this is impossible in the general case. Instead, our goal is just to get punt-to-a-human frequency low enough that very large translations are practical with a relatively small amount of human effort. We don't mind requiring users to make point changes to C codebases to get them through the translator when the code was horrible in C in the first place. As for unions, we'll do the stupidest possible thing that can work - translate them to structs and throw a warning. If the union was just a space optimization, that's it. If not, then a human must intervene. (Both projects are contingent on funding we don't yet have, alas. It's not like we need to buy a cyclotron or anything but we do need to be able to eat and pay rent for a couple years each.) It would sure help if Go had sum types. Has there been any discussion of adding these? -- <a href="http://www.catb.org/~esr/">Eric S. Raymond</a> My work is funded by the Internet Civil Engineering Institute: https://icei.org Please visit their site and donate: the civilization you save might be your own. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.