Re: [go-nuts] astutil.AddImport -- loosing all but the first import

2018-08-28 Thread naha
Thanks Todd. That fixed my problem. Concerning the dummy nodes to want to add to an AST, you could try adding dummy methods to make them to conform to ast.Stmt or whatever? On Tuesday, August 28, 2018 at 6:33:12 PM UTC-4, Todd Neal wrote: > > > > na...@mit.edu writes: > > > As can be seen

[go-nuts] astutil.AddImport -- loosing all but the first import

2018-08-28 Thread naha
As can be seen from my recent posts, I've been playing a lot with the automatic generation if go programs using go/ast and related packages. My current problem is that when I use astutil.AddImport. When I rn the program below, which creates a new ast.File and uses astutil.AddImport to import

Re: [go-nuts] Re: go/format ouputs spurious newlines

2018-08-14 Thread naha
I've read rather a lot of formal documentation where the authors were not so careful with their language, particularly with distinctions between words like "undefined" and "invalid". I think it a reasonable expectation that an object of type X returned by one function of a library be

Re: [go-nuts] Re: go/format ouputs spurious newlines

2018-08-14 Thread naha
The documentation can be interpreted as you say. If the resulting AST is subsequently inserted into a larger AST and then serialized, the source that is output can be syntactically invalid. It is unexpected (and I believe unreasonable) that serializing an AST can produce code that can't be

[go-nuts] Re: go/format ouputs spurious newlines

2018-08-14 Thread naha
The documentation for parser.ParseExpr says that the position information in the AST it returns "is undefined". I opserved the result as having position information. This looks like a bug. https://play.golang.org/p/tpzqDF3EZ_S demonstrates this bug. On Thursday, August 9, 2018 at 11:48:10

[go-nuts] Re: go/format ouputs spurious newlines

2018-08-09 Thread naha
I've done some further exploring. The expression computed by the line https://github.com/MarkNahabedian/Goshua/blob/ee72218487f39d2e97ade086df23dbcfcb4c2db3/rete/rule_compiler/rule_compiler.go#L214 has both a valid Pos() and a valid End(). parseExpression is defined at

[go-nuts] Re: go/format ouputs spurious newlines

2018-08-07 Thread naha
I think my problem might be related to the logic around line 982 of https://golang.org/src/go/printer/printer.go. I don't yet understand the distinction between the impliedSemi local variable and the impliedSemi field of printer. How would I fetch and build the go/printer code and install it

[go-nuts] globals defined by stringer utility

2018-05-05 Thread naha
I just learned about the stringer utility from Rob Pike's atricle about generate (https://blog.golang.org/generate). I was wondering why the code generated by stringer has it's data in global variables (example from the article) const _Pill_name = "PlaceboAspirinIbuprofenParacetamol" var

[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread naha
Thanks for your help and patience Alex. I guess I need to do something like https://play.golang.org/p/qURVD3of5oU but I find it kind of unclean to have to add private methods to do this. It wouldn't be appropriate to define a basicNode getter method on the node interface since basicNode is

[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread naha
b2 isn't in my most recent example. Thus gets the error that n2.inputs is not defined. func (n1 *basicNode) OutputsTo(n2 node) { n2.inputs = append(n2.inputs, n1) n1.outputs = append(n1.outputs, n2) } -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: what can I do about this interface conversion error

2018-05-01 Thread naha
I was expecting that since basicNode is anonymously embedded into TestNode and ActionNode, that the methods and fields of basicNode would all be present in TestNode and ActionNode. In that case I'd have expected https://play.golang.org/p/gIvykcxFTmQ to have worked. That shows that

[go-nuts] what can I do about this interface conversion error

2018-05-01 Thread naha
I don't know why I'm getting this interface conversion error or what to do about it. I define an interface, node, and a struct, basicNode that implements behavior common to all nodes. I also define ActionNode and TestNode which both anonymously embed basicNode. basicNode implements OutputsTo

[go-nuts] installing golang on MSWindows

2016-12-30 Thread naha
I installed golang into c:\go using the msi installer. When I look in tc:\go\lib all I see is the "time" directory. Where's the rest of the standard go libraries? If I look at the zip archive I see nothing else und How do I get a complete installation? er lib as well. This seems wrong. --