jcburley / joker

Small Clojure interpreter and linter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Insufficient Coverage of STD

jcburley opened this issue · comments

Though plenty of progress has been made, there's still not nearly good-enough coverage (autowrapping) of the functions available in Go's std library.

Looking at amd64-linux and amd64-darwin, of the total functions available for wrapping (as they're public), only about 20% are non-methods (do not have receivers) and so are currently eligible for autowrapping.

Of that 20%, between 20% and 30% are successfully converted (exact numbers depend on target system).

That's around 4-6% (let's say 5%) of the total public functions being converted.

The main obstacles to further wrapping now appears to be:

  • No support for native user-defined (std-defined) Go types in Joker, which blocks support for methods and for many functions that take such types as input arguments and/or return them among results. This is Issue #2 .
  • Imports aren't processed properly so a reference to e.g. x.y is not handled. This is Issue #4 .
  • Star types aren't supported correctly, so *Foo types for input arguments or returned results are not supported. This is Issue #3 .
  • Mutual type reference is not supported. It's not clear this happens often enough to worry about yet (it might be in the "noise" of the above issues), but it would appear to block some useful capabilities being exposed to Joker. This is Issue #1 .

The next course of action would appear to be to define deftype and friends for Joker, including both Joker-defined and Go (host) types, so Clojure-style special operators (such as .) would work on them. The gostd tool would then autogenerate the appropriate code and data structures for std. It's "just" a matter of deciding what that stuff should look like.

In the meantime, I can work on the Imports issue, as it's somewhat orthagonal to the other issues -- only "somewhat", though, because it's unlikely to be of much (if any) benefit until the Types issue is addressed.

Star types and mutual type reference need to be studied further, probably informed by the direction Joker goes in terms of exposing Go types (and objects) to Joker code.

Once those four issues are resolved, the coverage of STD could easily exceed 90%, and the remaining issues preventing full coverage should comprise some combination of simpler things (like supporting [][]byte as an input-argument type) and things we just don't see the need to support.

This has improved somewhat, though without better coverage of conversions between Clojure and Go types, it's a moot issue. The latest stats (on amd64-linux) are:

Totals: functions=7132 methods=5623 (78.84%) standalone=1509 (21.16%) generated=667 (44.20%)
        types=962 generated=344 (35.76%)

Note that most of the "obstacles", listed in the original issue comment, are no longer issues due mainly to the introduction of Go objects manipulable via Clojure code:

  • Non-trivlal-typed arguments and results (or among results) are now Go objects.
  • Imports are now processed (interpreted and generated) more consistently with how Go itself handles them
  • Star types have better support
  • Mutual type references should be less of an issue (if one at all) now that constructors are per-type and defer populating pointers to other types to those types' constructors, without needing to recurse on the information on those types' underlying types

A major TBD is handling methods (receivers) properly.

Much progress has been made. Here are the latest stats.

For amd64-darwin:

Totals: functions=3450 generated=2086 (60.46%)
          non-receivers=1487 (43.10%) generated=724 (48.69%)
          receivers=1963 (56.90%) generated=1362 (69.38%)
        types=959 generated=430 (44.84%)
        constants=3917 generated=3755 (95.86%)
        variables=413 generated=413 (100.00%)

For amd64-linux:

Totals: functions=3491 generated=2112 (60.50%)
          non-receivers=1526 (43.71%) generated=749 (49.08%)
          receivers=1965 (56.29%) generated=1363 (69.36%)
        types=966 generated=442 (45.76%)
        constants=4149 generated=3958 (95.40%)
        variables=413 generated=413 (100.00%)

For amd64-windows (out of date; to be updated soon):

Totals: functions=7074 methods=5562 (78.63%) standalone=1512 (21.37%) generated=627 (41.47%)
        types=973 generated=341 (35.05%)