Hi Max, gomacro is of course a beautiful work, and I encourage it. Thank you for gomacro. It is quite alot of work to build these interpreters, but they can be so valuable.
The issue I was having stems from the layers of Gijit being independent--having been reused from other projects like the Go compiler frontend, from LuaJIT, and from the Luar and golua libraries. Because of the way that I reused existing libraries, the typechecking info (from the gc frontend layer) isn't presently available to the golua Lua-to-binary-Go-method-call layer that is making the call. I'm not sure this is of general interest to the group, so feel free email me directly or file a github issue if you want to chat about the details more. Warm wishes, Jason On Friday, December 21, 2018 at 10:32:09 AM UTC-6, Max wrote: > > 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 the method "After" in the type `time.Time` (and `*time.Time`, > in case the method expects a pointer receiver) > 3. the returned reflect.Value is a `func (time.Time, time.Time) bool` > because when you lookup methods from `reflect.Type` > the receiver is **not** bound already > 4. it prepares an assignment `c := b.After` to be executed at runtime - > this instead will return a closure `func (time.Time) bool` because the > receiver is already bound to `b` > 5. it prepares a call `c(a)` to be executed at rutime - this will call > `b.After(a)` > > alternatively, 4. and 5. could become: > 4alt. it prepares a call `time.After(b, a)` to be executed at rutime by > using the reflect.Value returned by looking up the method "After" in the > type `time.Time` > > In both cases, gomacro detects with a method lookup from `time.Time` that > "After" is a method and behaves accordingly at "compile time", > without waiting for the reflect.Value of `b.After`, which is only > available at runtime. > > It's not clear to me why you had to resort to distinguish methods vs. > functions *after* you obtained the reflect.Value `b.After` instead of > distinguishing them *before* > i.e. during typecheck or a similar phase - can you explain? > > Regards, > > cosmos72 > > > > -- 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.