Re: [go-nuts] Homoiconic metaprogramming in Go

2018-12-17 Thread howardcshaw
I was not responding to it being or not being metaprogramming, just the 
implication that go generate commands were provided some sort of special 
access. They do not have any access to parsed syntax trees - they can 
themselves parse source files and thus create syntax trees. On re-reading, 
I can see how your description still fits, I was reading an implication 
into it that is not actually stated in the text. Mea culpa.

Howard

-- 
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.


Re: [go-nuts] Homoiconic metaprogramming in Go

2018-12-14 Thread Michael Jones
I've been thinking about a related idea for the past while ... "pure
functions" ... i'll post an email about it now.

On Fri, Dec 14, 2018 at 6:06 AM roger peppe  wrote:

> On Fri, 14 Dec 2018 at 14:01,  wrote:
>
>> Not sure where you got this impression - commands run by go generate have
>> only the OS environment. They are just ordinary commands, as might be run
>> by any shell script, just the calls to them are integrated into the Go
>> tooling.
>>
>> Tools that seem to access go syntax trees and the like? They are simply
>> using the parser and AST tools made available by Go to parse go code, and
>> that can be done at any time, not just during go generate.
>>
>
> Yup. How is that not metaprogramming though?
>
> --
> 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.
>


-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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.


Re: [go-nuts] Homoiconic metaprogramming in Go

2018-12-14 Thread roger peppe
On Fri, 14 Dec 2018 at 14:01,  wrote:

> Not sure where you got this impression - commands run by go generate have
> only the OS environment. They are just ordinary commands, as might be run
> by any shell script, just the calls to them are integrated into the Go
> tooling.
>
> Tools that seem to access go syntax trees and the like? They are simply
> using the parser and AST tools made available by Go to parse go code, and
> that can be done at any time, not just during go generate.
>

Yup. How is that not metaprogramming though?

-- 
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.


Re: [go-nuts] Homoiconic metaprogramming in Go

2018-12-14 Thread howardcshaw
Not sure where you got this impression - commands run by go generate have 
only the OS environment. They are just ordinary commands, as might be run 
by any shell script, just the calls to them are integrated into the Go 
tooling.

Tools that seem to access go syntax trees and the like? They are simply 
using the parser and AST tools made available by Go to parse go code, and 
that can be done at any time, not just during go generate.

Howard

On Friday, December 14, 2018 at 3:40:40 AM UTC-6, rog wrote:
>
> To answer your original question, yes, it is possible to do 
> metaprogramming in Go, although not at compile time.
>
> That's essentially what the go generate command is about - a command run 
> by go generate has access to parsed syntax trees, type information and 
> anything else it likes (bar actual compiler internals), and can generate 
> whatever code it likes.
>
> For example, I think it's pretty clear that what the Wire project does 
> (see https://github.com/google/wire/blob/master/docs/guide.md) is 
> metaprogramming, to some degree or other.
>
>   cheers,
> rog.
>
>> -- 
>>
>>

-- 
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.


Re: [go-nuts] Homoiconic metaprogramming in Go

2018-12-13 Thread Ian Lance Taylor
On Thu, Dec 13, 2018 at 9:25 PM Dmitry Ponyatov  wrote:
>
> Is it possible to do metaprogramming in Go?
>
> What I want to have is a way to run arbitrary code in compile time, which has 
> full access to compiler data structures
> (parsed syntax trees, compiler stages callbacks, direct code generator calls).
>
> As a variant, it can be some Lisp system runs between parser stage and the 
> rest of  Go compiler.

Go doesn't support this.  Sorry.

Ian

-- 
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.


[go-nuts] Homoiconic metaprogramming in Go

2018-12-13 Thread Dmitry Ponyatov
Is it possible to do metaprogramming in Go?

What I want to have is a way to run arbitrary code in compile time, which 
has full access to compiler data structures
(parsed syntax trees, compiler stages callbacks, direct code generator 
calls).

As a variant, it can be some Lisp system runs between parser stage and the 
rest of  Go compiler. 

-- 
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.