Re: [go-nuts] Recursive type definition

2021-05-04 Thread Max
The package go/types, which can represent Go types, represents recursive types with cycles. It also has explicit code to detect and handle such cycles when comparing types for identity, assignability, etc. Go compiler represents type with a different package, internal to Go compiler which is

Re: [go-nuts] go build error in darwin: duplicate symbol

2021-03-22 Thread Max Xu
But I didn't write cgo code in my project. The weird part is I can build success with *GOOS=linux go build*, but failed with *GOOS=darwin go build* On Friday, March 19, 2021 at 5:11:57 AM UTC+8 Ian Lance Taylor wrote: > On Thu, Mar 18, 2021 at 9:55 AM Max Xu wrote: > > > &

[go-nuts] go build error in darwin: duplicate symbol

2021-03-18 Thread Max Xu
Hi all, I'm running into a weird bug: Failed with command: GOOS=darwin go build Bug success with: GOOS=linux go build The failed Message: /usr/local/opt/go/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1 duplicate symbol '_readdrivestat' in:

Re: [go-nuts] should I pass functions as parameter of a go routine?

2021-03-06 Thread Max Renaud
In your second example, the address of wg doesn't change with each iteration so you can use: for _, onedoer := range d { go func(od *doer) { od.do() }(onedoer) } https://play.golang.org/p/A1dAUuyvg9T On Thursday, March 4, 2021 at 8:50:19 AM UTC-8 Julien Pivotto wrote: > Thank you for your

[go-nuts] Re: Java version of keydb

2020-12-12 Thread max...@gmail.com
i can not open the java version link https://github.com/robaho/jkeydb . it's returns 404 code On Saturday, December 12, 2020 at 10:04:42 PM UTC+3 ren...@ix.netcom.com wrote: > Hi all, > > I thought this might be of interest to some. I released a Java version of > keydb

[go-nuts] Re: CSS-like selectors for Go AST?

2020-10-21 Thread Max
n Size() int Get(i int) Ast Set(i int, child Ast) New() Ast // returns a copy of Ast. the children are not copied } ``` On Wednesday, October 14, 2020 at 8:06:57 PM UTC+2 cpu...@gmail.com wrote: > Hi Max, > > Great answer, thank you! Exactly what I was looki

[go-nuts] Re: Any embedded scripting language for Go

2020-10-21 Thread Max
It's also possible to embed a Go interpreter in a Go App - in this way, the scripting language is Go itself. There are several fairly complete Go interpreters around, including at least: https://github.com/cosmos72/gomacro (disclaimer: I am the author) https://github.com/traefik/yaegi

[go-nuts] Re: CSS-like selectors for Go AST?

2020-10-14 Thread Max
I can only agree, traversing or navigating Go AST is cumbersome for at least two reasons: 1. each type has its own fields - no uniform API is available 2. you often need type assertions on fields because they have interface type instead of concrete type I developed a wrapper around them to

Re: [go-nuts] Go 2 review process

2020-07-18 Thread Max
I have a proposal for improving Go proposal procedure. It stems from two "issues" highlighted in several occasions: 1. core Go team is spending an increasing amount of time discussing a larger number of proposals. All of them are commented and discussed by core Go team, and in the end

Re: [go-nuts] Re: Generics and parentheses

2020-07-15 Thread Max
I think square brackets are better than parentheses for several reasons: 1. fewer parser ambiguities (see the post that started this thread) - thus fewer cases where programmers must remember "oh, this is a special case, I must put additional parentheses somewhere" 2. programmers can

[go-nuts] Re: [generics] Zero value

2020-06-22 Thread Max
Types are not first-class in Go, thus T.someMethod() is somewhat an unusual syntax. The proposal to use 'T{}' to mean zero value of T breaks Go compatibility promise: if T is a map type or a slice type, 'T{}' already has a meaning: create a non-nil,

[go-nuts] Re: go/types: types.Named hides intermediate names

2019-11-20 Thread Max
. the following works: var x X var t time.Time = time.Time(x) var x2 X = X(t) On Wednesday, November 20, 2019 at 12:18:28 PM UTC+1, Max wrote: > > > It's part of the language specifications https://golang.org/ref/spec#Types. > It says: > type ( > B1 string > B2 B1 > )

[go-nuts] Re: go/types: types.Named hides intermediate names

2019-11-20 Thread Max
It's part of the language specifications https://golang.org/ref/spec#Types. It says: type ( B1 string B2 B1 ) "The underlying type of [...] B1 and B2 is string" In other words, when you write type X time.Time there is absolutely *no direct* connection between the types X and time.Time:

[go-nuts] Re: Any way to print a 'struct g' within delve/gdb

2019-11-12 Thread Max
I just tried with latest delve, and 'p runtime.m0.curg' is enough: (dlv) p runtime.m0.curg *runtime.g nil (dlv) break main.main (dlv) continue [...] (dlv) p runtime.m0.curg *runtime.g { stack: runtime.stack {lo: 824635269120, hi: 824635285504}, stackguard0: 82463527, stackguard1:

[go-nuts] Re: Roadblock for user-implemented JIT compiler

2019-11-02 Thread Max
On Friday, November 1, 2019 at 8:58:13 AM UTC+1, Sokolov Yura wrote: > > Don't forget about calling to write barriers. Of course. Second update: calling arbitrary Go functions from ARM64 JIT code works too :) See https://github.com/cosmos72/gomacro/blob/master/jit/_hide_from_stack -- You

[go-nuts] Re: Gofmt needs to allow newline-operator

2019-10-31 Thread Max
Indeed. It's not just a matter of gofmt: the "implicit semicolon" rule of Go syntax is triggered at the end of this line ``` if Variable1 == true ``` causing it to be parsed as ``` if Variable1 == true; ``` Any operator in the following line arrives too late to change that. So to implement what

[go-nuts] Re: Roadblock for user-implemented JIT compiler

2019-10-31 Thread Max
the same trick in ARM64 assembler - there are differences, and I am not yet sure it will work. cosmos72 On Wednesday, October 23, 2019 at 5:35:40 PM UTC+2, Max wrote: > > Thanks for the idea Rick, > > there is one detail I do not understand: > JIT code does not have a sta

[go-nuts] Re: Roadblock for user-implemented JIT compiler

2019-10-23 Thread Max
would likely slow you down. Likewise forking would > come with the usual maintenance/merge headaches. > > > > On Wednesday, October 23, 2019 at 1:50:51 PM UTC+1, Max wrote: >> >> Hello gophers, >> >> My recent attempt at creating a JIT compiler in Go to speed up

[go-nuts] Roadblock for user-implemented JIT compiler

2019-10-23 Thread Max
Hello gophers, My recent attempt at creating a JIT compiler in Go to speed up my interpreter https://github.com/cosmos72/gomacro hit an early roadblock. In its current status, it can compile integer arithmetic and struct/array/slice/pointer access for amd64 and arm64, but it cannot allocate

[go-nuts] Re: go/types.Named from go/ast

2019-10-22 Thread Max
On Tuesday, October 22, 2019 at 7:26:04 AM UTC+2, Frew Schmidt wrote: > > Hello Gophers! > > I'm trying to migrate some code that uses `reflect.Type` at runtime to > `types.Type` from `go/ast` built ahead of time. I got a pretty good way > (converted all the code and got it to successfully

Re: [go-nuts] Re: Contracts Draft: why are method pointers allowed

2019-08-01 Thread Max
I think that a single syntax allowing both pointer receivers and value receivers - with no mechanism to distinguish them - creates unnecessary ambiguity, and in some cases it can concretely be a problem. Consider the following example, adapted from 'math/big.Int`: ``` contract Comparable(T) {

[go-nuts] Re: readonly []byte required

2019-07-05 Thread Max
I think it could be a useful optimization. There are at least in two different (and much more general) proposals that, if accepted, would include readonly slices as a special case. The the compiler could recognize that a readonly slice created from a string can reuse string's underlying data:

Re: [go-nuts] reflect Call method on nested struct

2019-05-29 Thread Max
There is another improvement you can do: you are currently using cfg := Config{Name: } r := reflect.ValueOf(cfg) which means that 'r' will contain a copy of 'cfg' and will not be settable. If instead you use: r := reflect.ValueOf().Elem() then r will contain a *pointer* to the original 'cfg'

[go-nuts] Re: Interesting public commentary on Go...

2019-05-29 Thread Max
Although it's slightly off-topic, there are already some Go forks or variants that implement generics. One is Fo https://github.com/albrow/fo - a source-to-source transpiler that converts "Go with generics" to plain Go Another is my https://github.com/cosmos72/gomacro - a Go interpreter with

[go-nuts] Re: Adding a timeout to a script interpreter (without leaking a goroutine)

2019-05-23 Thread Max
A bit less "funky" idea - I currently use it in my https://github.com/cosmos72/gomacro to interrupt the interpreter if the user hits Ctrl+C. Caveat: I don't know how difficult is to adapt it to GoAWK. The idea is conceptually simple: loop unrolling. The details are slightly tricky: unroll the

[go-nuts] Re: Adding a timeout to a script interpreter (without leaking a goroutine)

2019-05-21 Thread Max
Using `context` is the recommended mechanism to pass timeouts and other information to functions, so it's probably already the "best" way, at least from the design point of view. I recommend benchmarking it before searching for other solutions: if it turns out to cause excessive slowdown, there

Re: [go-nuts] the Dominance of English in Programming Languages

2019-04-29 Thread Max
I am Italian, and I learned to program quite early - before really knowing English. In my experience, the fact that most programming languages use English keywords is not a big obstacle - for two reasons: 1) each programming language has very few reserved keywords - dozens at most, compared to

[go-nuts] Re: Q on using reflect: how to distinguish methods from functions?

2018-12-21 Thread Max
Hello Jason, do you have the time to explain this problem more in detail? My Go interpreter gomacro (I think you already met it), solves the problem of invoking `b.After(a)` as follows at "compile time", i.e. during typecheck and translation: 1. detects that `b` is a `time.Time`. 2. looks up

[go-nuts] Re: Homoiconic metaprogramming in Go

2018-12-19 Thread Max
As Ian Lance Taylor answered already, Go language and main Go compilers (go and gccgo) do not support this. My unofficial Go interpreter https://github.com/cosmos72/gomacro instead does, I even presented its AST manipulation and code generation facilities (heavily modeled after Common Lisp) at

Re: [go-nuts] How to get current goroutine id?

2018-10-30 Thread Max
I agree on the fact that passing a Context everywhere is impossible in some cases - just think about the many APIs (from standard library and 3rd parties) that do not accept a Context - and in some other cases very complicated, requiring extensive refactoring. I also agree with the

[go-nuts] Re: C.malloc of Go type?

2018-05-19 Thread Max
On Saturday, May 19, 2018 at 10:42:12 PM UTC+2, Max wrote: > > > func mallocList() *List { > const n = unsafe.Sizeof(List{}) > p := C.malloc(C.ulong(n)) > C.memset(p, C.int(n), 0) > return (*List)(p) > } > I swapped the arguments to C.memset(). Th

[go-nuts] C.malloc of Go type?

2018-05-19 Thread Max
is: is it allowed to take the unsafe.Pointer returned by C.malloc() and convert it to a pointer to a Go struct type? In practice: is the following code valid ? Thanks, Max // - package main /* #include

Re: [go-nuts] [ANN] gomacro v2.6 - interactive Go interpreter, now with debugger

2018-04-29 Thread Max
About the "other languages extensions": it's obviously easier than modifying the official Go compiler, but it's usually still a major task, especially if it involves modifying the "poor man's compiler" fast.Comp which converts a parsed ast.Node into a tree of function closures for execution.

Re: [go-nuts] [ANN] gomacro v2.6 - interactive Go interpreter, now with debugger

2018-04-29 Thread Max
Done and documented :) As I also wrote in README.md, see https://github.com/cosmos72/gomacro/blob/master/fast/cmd.go#L37 for the documentation and API to define new special commands. The TL;DR summary is: choose a name for the new command, write a function with signature func(interp

Re: [go-nuts] [ANN] gomacro v2.6 - interactive Go interpreter, now with debugger

2018-04-28 Thread Max
Adding custom :foo commands is trivial, it's just a matter of exporting an api to do register them (the api exists already, but it's not exported and I would use the occasion to improve it). I should have time to do it tomorrow and document an example. About the license: yes, I am still

[go-nuts] How to avoid using goroutine id for Go interpreter with functions, goroutines, and debugger?

2018-04-28 Thread Max
I have the feeling this is a very advanced and very specific question, still I would appreciate indications on how to avoid the uncomfortable corner I find myself in, namely that I found no alternative to goroutine id for my (quite complicated) use case. Let me explain: My Go interpreter

[go-nuts] Re: [ANN] gomacro v2.6 - interactive Go interpreter, now with debugger

2018-04-28 Thread Max
That's basically what I have done, and it's both pretty declarative (although not fully) and statically typed. If you are interested, take a look at https://github.com/cosmos72/gomacro/blob/master/example/make_fibonacci.gomacro and the file it generates when executed by gomacro in preprocessor

[go-nuts] Re: [ANN] gomacro v2.6 - interactive Go interpreter, now with debugger

2018-04-27 Thread Max
Hello Louky, thanks for the question :) Support for out-of-order code is one of the last missing features, and I am am pretty confident it can be added with reasonable effort, given the large amount of static type analysis that gomacro already performs. In my opinion, the hardest obstacle to

[go-nuts] [ANN] gomacro v2.6 - interactive Go interpreter, now with debugger

2018-04-27 Thread Max
er version of gomacro). As usual, feedback is welcome :) Max -- 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...@goo

[go-nuts] Re: [ANN] Go Jupyter kernel and an interactive REPL

2018-01-29 Thread Max
Hello yunabe, congratulations for your impressive work! The Go REPL looks really complete and user-friendly :) I am the author of https://github.com/cosmos72/gomacro;>gomacro - the interpreter used by gophernotes, and I am very interested in understanding how lgo REPL is implemented: I had a

Re: [go-nuts] syscall.SetNonblock stopped working in Go 1.9.3

2018-01-25 Thread Max
effects seems very unexpected and surprising at least to me. Best regards, Max As of 1.9 os.Pipe returns non-blocking descriptors by default. In > order to be consistent with past releases, when you call the Fd > method, the descriptor is explicitly set back into blocking mode, &

Re: [go-nuts] syscall.SetNonblock stopped working in Go 1.9.3

2018-01-25 Thread Max
he details above on the bug report too. Regards, Max On Thursday, January 25, 2018 at 11:03:47 AM UTC+1, Steven Hartland wrote: > > I checked this on FreeBSD and it still works, so seems like it could be a > macOS specific issue. > > You should raise a bug here: > https:/

Re: [go-nuts] Mapping function name/address to rtype/functype

2017-10-26 Thread max . shavrick
Maybe I have some false assumptions here, but if I had a dynamically-linked go library that I stripped, how would I be able to use reflection at runtime when using things from this library. (Does go support making dynamic libraries?) Thank you Max On Thursday, October 26, 2017 at 5:52:49 PM

[go-nuts] Architectural question

2017-10-07 Thread max
Hi, i am challenged to develop an effective failover mechanism of aggregated notification of certain transactions. I have transactions by merchant. Every hour i need to send email (and some other) notifications, aggregated by the merchants to specific recipients. Now i am doing it with

[go-nuts] [ANN] gomacro v2.0 - Go interpreter with REPL, Eval and code-generating macros

2017-06-30 Thread Max
1.9 Beta 1. Feedback welcome :) Max -- 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, v

[go-nuts] Re: Runtime code generation?

2017-05-18 Thread Max
asible too. But it will not scale much: each compiled plugin contains all its dependencies, thus compiling and loading a new plugin for each small snippet of code generated at runtime will very quickly consume a lot of RAM. Regards, Max On Thursday, May 11, 2017 at 12:19:51 AM UTC+2, Erwin Driessens wrot

[go-nuts] go/cmd erroneous compile error: initialization loop

2017-05-02 Thread max . dergosits
This gives me a compilation error: https://play.golang.org/p/5nSLXw9n82 but this does not: https://play.golang.org/p/maaTNOVeqM I expected to see no error, and have a valid go program, since there are no real initialization dependencies. This is the output I got: >

Re: [go-nuts] Question about go test and -cpuprofile

2017-03-03 Thread max . faceless . frei
I thought that hitting CTRL+C(i.e. sending SIGINT) is a relatively common way to abort tests that run for too long. суббота, 4 марта 2017 г., 10:32:47 UTC+5 пользователь Ian Lance Taylor написал: > > On Fri, Mar 3, 2017 at 9:18 PM, > wrote: > >> I would not expect to

Re: [go-nuts] Question about go test and -cpuprofile

2017-03-03 Thread max . faceless . frei
> > I would not expect to get a CPU profile if you hit ^C. > Just curious as of why? I mean we could use *signal.Notify* for that, no? пятница, 3 марта 2017 г., 23:04:30 UTC+5 пользователь Ian Lance Taylor написал: > > On Fri, Mar 3, 2017 at 9:41 AM,

[go-nuts] Question about go test and -cpuprofile

2017-03-03 Thread max . faceless . frei
Say you have a package with a test suite that completes in 30 seconds on average. You run: go test -cpuprofile cpu.pprof -timeout 10s > Then whether you abort tests by hitting CTRL+C or they end with a panic due to a low timeout value, in both cases, *cpu.pprof* will be empty. Is this intended

[go-nuts] bombardier - Fast cross-platform HTTP benchmarking tool written in Go

2017-02-23 Thread max . faceless . frei
https://github.com/codesenberg/bombardier I just released a v1.0 of my benchmarking tool. If you have been looking for a *wrk*/*weighttp *replacement for Windows or want something more performant than, say,