glycerine / zygomys

Zygo is a Lisp interpreter written in 100% Go. Central use case: dynamically compose Go struct trees in a zygo script, then invoke compiled Go functions on those trees. Makes Go reflection easy.
https://github.com/glycerine/zygomys/wiki
BSD 2-Clause "Simplified" License
1.71k stars 81 forks source link

Missing function for milliseconds #35

Closed jkleiser closed 5 years ago

jkleiser commented 5 years ago

I see that zygo has time related functions like now, astm and timeit, but I cannot find any function returning milliseconds since some fixed time (1970-01-01), or since zygo launch. Floating point seconds with decimals could also do.

glycerine commented 5 years ago

Reasonable. Would you kindly send a pull request?

https://github.com/glycerine/zygomys/blob/master/zygo/time.go is probably the best place to add such things.

jkleiser commented 5 years ago

I will give it a try. Maybe later this week.

jkleiser commented 5 years ago

It took a while before I got it right, but now I have a function (in my local fork) that returns the milliseconds based on time.Now().UnixNano(). I have two questions: What do you prefer that I name this function, unixmillis or just millis? In the file cmd/zygo/main.go, line 9, I had to change the import to "github.com/jkleiser/zygomys/zygo". Is there a way to write this to avoid it being so github specific?

glycerine commented 5 years ago

unixmillis or just millis?

your call, but I like the shorter name

In the file cmd/zygo/main.go, line 9, I had to change the import to "github.com/jkleiser/zygomys/zygo". Is there a way to write this to avoid it being so github specific?

not that I'm aware of. If you file a PR though, leave it pointing at glycerine/zygomys so the project still builds by default with a go get.

jkleiser commented 5 years ago

Agreed on "millis".