FAQ
What is the right way to get an ast.Expr representing the type of arbitrary
expressions in an ast? I am trying to insert a function literal into the
ast around arbitrary expressions - the function literal's FuncType's
FieldLists' Fields need to be populated with type expressions that match
the wrapped expression. Example:

x := someFunc()
y := z + x

Is there a way to get ast type expressions for "someFunc()" and "z+x"
without manually locating the decl/assign nodes for each func/var and
reading the decl's type expr or divining it from a literal on the rhs of
assignment? Is this something that the go/types package will eventually do?

--

Search Discussions

  • Robert Carlsen at Oct 22, 2012 at 10:49 pm
    No Love?
    On Sunday, October 21, 2012 6:11:22 PM UTC-5, Robert Carlsen wrote:

    What is the right way to get an ast.Expr representing the type of
    arbitrary expressions in an ast? I am trying to insert a function literal
    into the ast around arbitrary expressions - the function literal's
    FuncType's FieldLists' Fields need to be populated with type expressions
    that match the wrapped expression. Example:

    x := someFunc()
    y := z + x

    Is there a way to get ast type expressions for "someFunc()" and "z+x"
    without manually locating the decl/assign nodes for each func/var and
    reading the decl's type expr or divining it from a literal on the rhs of
    assignment? Is this something that the go/types package will eventually do?
    --
  • Rémy Oudompheng at Oct 22, 2012 at 10:36 pm

    On 2012/10/23 Robert Carlsen wrote:
    No Love?

    On Sunday, October 21, 2012 6:11:22 PM UTC-5, Robert Carlsen wrote:

    What is the right way to get an ast.Expr representing the type of
    arbitrary expressions in an ast? I am trying to insert a function literal
    into the ast around arbitrary expressions - the function literal's
    FuncType's FieldLists' Fields need to be populated with type expressions
    that match the wrapped expression. Example:

    x := someFunc()
    y := z + x

    Is there a way to get ast type expressions for "someFunc()" and "z+x"
    without manually locating the decl/assign nodes for each func/var and
    reading the decl's type expr or divining it from a literal on the rhs of
    assignment? Is this something that the go/types package will eventually do?
    Yes, the go/types package aims at doing that, but it is still in
    development. It is thus called exp/types in the current repository.

    Rémy.

    --
  • Robert Carlsen at Oct 22, 2012 at 11:24 pm
    Thanks. I'll be anxiously awaiting the package's completion.
    On Monday, October 22, 2012 5:37:00 PM UTC-5, Rémy Oudompheng wrote:

    On 2012/10/23 Robert Carlsen <princessa...@gmail.com <javascript:>>
    wrote:
    No Love?

    On Sunday, October 21, 2012 6:11:22 PM UTC-5, Robert Carlsen wrote:

    What is the right way to get an ast.Expr representing the type of
    arbitrary expressions in an ast? I am trying to insert a function
    literal
    into the ast around arbitrary expressions - the function literal's
    FuncType's FieldLists' Fields need to be populated with type
    expressions
    that match the wrapped expression. Example:

    x := someFunc()
    y := z + x

    Is there a way to get ast type expressions for "someFunc()" and "z+x"
    without manually locating the decl/assign nodes for each func/var and
    reading the decl's type expr or divining it from a literal on the rhs
    of
    assignment? Is this something that the go/types package will
    eventually do?

    Yes, the go/types package aims at doing that, but it is still in
    development. It is thus called exp/types in the current repository.

    Rémy.
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 21, '12 at 11:11p
activeOct 22, '12 at 11:24p
posts4
users2
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase