On Friday, December 14, 2018 at 2:45:44 PM UTC-6, Jason E. Aten wrote:
>
>
>
> On Friday, December 14, 2018 at 2:19:05 PM UTC-6, Kevin Malachowski wrote:
>>
>> Why do you need to figure out whether something is a Method? Usually it 
>> doesn't really matter.
>>
>> (I don't have an answer for you, but if you give more background I or 
>> someone else may be able to be more useful; trying to avoid the X-Y 
>> problem.)
>>
>
> It matters for translating Go calls (method and function) properly into 
> Lua calls:
>
>
> https://github.com/glycerine/luar/commit/eccbbe2e420d5a2cffb2a80e2dca1c31a5b89d7d
>  
>
>
For full context, here is a small example of what gijit/gi -- my Golang 
REPL that uses LuaJIT as its back end -- can do. This is calling back into 
the Go standard libraries such as "time" to use their functionality, even 
after having translated from Go -> Lua.  Go compiled code can be invoked 
from the interpreter, for speed. Even though LuaJIT is quite speedy, 
compiled Go code is usually faster. The fix I pointed to above makes the 
b.After(a) call work. Otherwise the 'a' argument was getting used 
twice/mixed up with 'b'.

~/go/src/github.com/gijit/gi (master) $ gi
====================
gijit: a go interpreter, just-in-time.
====================
https://github.com/gijit/gi
Copyright (c) 2018, Jason E. Aten. All rights reserved.
License: 3-clause BSD. See the LICENSE file at
https://github.com/gijit/gi/blob/master/LICENSE
====================
  [ gijit/gi is an interactive Golang environment,
    also known as a REPL or Read-Eval-Print-Loop.]
  [ at the gi> prompt, type ctrl-d to exit.]
  [ at the gi> :?   or :help for help.]
  [ $ gi -h for flag help, when first launching gijit.]
  [ $ gi -q to start quietly, without this banner.]
====================
built: '2018-12-14T15:58:00-0600'
last-git-commit-hash: 'b3294722551defbd98a98ad09965f87b30337af6'
nearest-git-tag: 'v1.9.8'
git-branch: 'master'
go-version: 'go_version_go1.10.3_darwin/amd64'
luajit-version: 'LuaJIT_2.1.0-beta3+jea-int64-additions'
==================
Using static prelude.
gi> import "time"

elapsed: '203.041µs'
gi> a := time.Now()

elapsed: '176.173µs'
gi> b := time.Now()

elapsed: '168.676µs'
gi> println(a.After(b))
false

elapsed: '173.885µs'
gi> println(b.After(a))
true

elapsed: '265.616µs'
gi> a
2018-12-14 16:05:16.799067846 -0600 CST m=+5.198567213

elapsed: '202.912µs'
gi>
 

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

Reply via email to