Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/ast: API #2854

Closed
rsc opened this issue Feb 2, 2012 · 2 comments
Closed

go/ast: API #2854

rsc opened this issue Feb 2, 2012 · 2 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Feb 2, 2012

Suggestions (take or leave)

The various top-level functions all seem out of place.
Should they be methods?
Should the Fileset be recorded in the Package and File?
They are big enough that the extra space would not be
noticeable, and it would make them a little easier to use.
@griesemer
Copy link
Contributor

Comment 1:

The AST is kept minimal, it's essentially just a data structure (but for the Pos(),
End() methods). One could add more methods, but the question arises where to stop: When
is a method not part of the AST anymore, but a function operating on the AST. The
decision - made long ago - was to keep the AST free of such methods.
Some of the functionality crept it over time, yet the AST is still just a data
structure. Once such functionality becomes methods, one might ask why is printing, type
checking, etc. not implemented as methods. It's better to not add all this to the AST.
It would be nice if the FileSet would be recorded in the Package and File, but it
doesn't solve all use cases (operations om portions of the AST). Also, it doesn't work
if an AST contains pieces from different files (which is theoretically possible). I'd be
ok with that change as it is backward-compatible (except for the multiple files issue).
However, the go/printer would still need the separate FileSet for printing of partial
ASTs (decls).

Status changed to Thinking.

@rsc
Copy link
Contributor Author

rsc commented Feb 24, 2012

Comment 2:

It's too late to change the API.

Status changed to Retracted.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants