Skip to content

Support methods defined on embedded types, rename 'refTo' to '*', etc.

Pre-release
Pre-release
Compare
Choose a tag to compare
@jcburley jcburley released this 12 Oct 05:07
· 151 commits to gostd since this release

Many methods, available to Go code via types embedded in interfaces and structs, are now also made available to Joker code. E.g. (.Close c) on a net.TCPConn connection c now works, even though TCPConn itself does not implement Close, because its struct embeds the (non-exported) net.conn type, which does implement Close. Note that gostd tries to avoid wrapping a method, available via an embed, that is explicitly implemented by the containing type. For example, text/template/parse.DotNode is a struct that embeds NodeType, for which the Type() method is defined; but, since DotNode implements its own Type(), that method, not NodeType's, is left as the wrapped type for e.g. (.Type d), where d is typeDotNode.

A value receiver for a reference (wrapped by a GoObject) can now be called without having to explicitly dereference the object. Some support for calling a pointer receiver for a value is now provided, but doesn't work in the straightforward case of a GoObject wrapping that value, as the Go runtime (specifically, the reflect package) does not always see such a value as capable of being addressable (reflect.CanAddr() fails).

Pointer types are named using *, instead of refTo, as * is a reasonably common character in Clojure symbols. However, as [ and ] are not valid (without escaping in some fashion), arrays/slices are still named using arrayOf, leading to some bodges such as arrayOf*Foo. It's unclear whether any elegant solution to this problem exists.

Preliminary support for func() types (taking no arguments and returning no value) is provided. However, it's purely experimental, and no attempt is made to ensure single-threading behavior with respect to other running Joker code. As the only test case currently defined invokes the function on a separate thread from the main thread passing the function, it's either happenstance, or the very limited use case of the Joker code that implements the function, that allows that test case to pass.

Substantial refactoring of gostd continues with this preliminary release, but much more is planned, some of which will likely be visible to Joker code calling the wrapped namespaces.