Releases: jcburley/joker
Support typed constants, all constants, and arrays with constant lengths
All (exported) constants are now wrapped; evaluation of constant expressions is now done via go/types
, go/importer
, and go/constant
, rather than via custom code in gostd
.
Constant types are now preserved. E.g. go.std.net/FlagUp
is of type net.Flags
, not Number
, so this now works (as go.std.net/Flags
is the type for FlagUp
and defines a String()
method for it and other constants), instead of just 1N
being printed:
user=> go.std.net/FlagUp
up
user=> (int go.std.net/FlagUp)
1
user=>
Constants and variables whose names match Joker type names are no longer renamed away. Use explicit namespace resolution to specify them; or, if referring a namespace that shadows a Joker type (which is not recommended), quote the type when using it as a tag. E.g.:
user=> Int
Int
user=> (type Int)
Type
user=> go.std.go.constant/Int
3
user=> (use 'go.std.go.constant)
nil
user=> Int
3
user=> (type Int)
GoObject
user=> (defn ^Int foo [])
user=> (meta (var foo))
{:line 12, :column 1, :file "<repl>", :ns user, :name foo, :tag 3, :arglists ([])}
user=> (defn ^"Int" foo [])
user=> (meta (var foo))
{:line 14, :column 1, :file "<repl>", :ns user, :name foo, :tag "Int", :arglists ([])}
user=>
Note that the first argument to catch
in a try
is known to specify a type, so the builtin Joker types will be checked first, as will likely be desirable (since catch
does not support GoType
s). E.g.:
user=> (use 'go.std.go.scanner)
nil
user=> Error
go.std.go.scanner/Error
user=> (type Error)
GoType
user=> (try true (catch Error e))
true
user=> (try true (catch go.std.go.scanner/Error e))
<repl>:26:18: Parse error: Unable to resolve type: go.std.go.scanner/Error, got: {:type :var-ref, :var #'go.std.go.scanner/Error}
user=>
The BigFloat
type is now supported for std
-generated libraries (namespaces in the std
subdirectory and built into Joker).
Further, BigFloat
s created from strings (such as 1.3M
) are given a minimum precision of 53 (the same precision as a Double
, aka float64
) or more precision based on the number of digits and the number of bits each digit represents (3.3 for decimal; 1, 3, or 4 for binary, octal, and hex).
All arrays with constant lengths are now supported. Previously only easily-evaluated lengths (such as literal constants) were supported; now, any constant expression works. This results in more functions being wrapped.
A new joker.core/precision
function has been introduced mainly to inspect BigFloat
types, though it supports a few others.
Become Useful If Not Elegant
This release wraps most (90% or more) functions, provides constructors for most defined types, and supports many useful operations.
For example, this version of Joker can send emails via SMTP.
Much still needs to be done; see the docs for a partial list. Meanwhile, here are some highlights (from GOSTD.md
) of what's new:
...
arguments are now supported for functions, methods, and receivers, unless the underlying type is any other type Joker decides to pass by reference (currently these are all non-empty struct{}
types; as a result, reflect.Append()
is unsupported). E.g.:
user=> (go.std.fmt/Println (go.std.net/IPv4 1 2 3 4) (go.std.net/IPv4Mask 255 255 255 127))
1.2.3.4 ffffff7f
[17 nil]
user=>
^GoObject
arguments are extended to support many native Joker types via their underlying (Native
) types. E.g.:
user=> (go.std.fmt/Println 1 2 3 4)
1 2 3 4
[8 nil]
user=>
[]byte
arguments and fields are now supported in function calls and ctors, and also support automatic conversion from strings (e.g. an object of type String
). There are more conversions like this to come, but this is a nice proof-of-concept, as it enables (for example) sending an email to an SMTP server.
A Vector
or Seq
may be provided in lieu of a String
(this might be too general!). E.g.:
user=> (go.std.fmt/Printf [65 66 67 10])
ABC
[4 nil]
user=>
Got chan
and (empty) struct{}
types working at a rudimentary level.
Receivers that have no return values are now implemented; their Joker wrappers return NIL
, just as for regular functions and methods.
Types defined (recursively) in terms of builtin types are now pass-by-value (and construct-by-value), as is struct{}
.
Note that constructors for pass-by-reference types return reference types. E.g. (new Foo ...)
returns refToFoo
. Assuming the Go code defines methods on *Foo
, they should work on the result; else, one should be able to dereference and then invoke them, as in (Go (deref my-foo) :SomeMethod ...)
.
Though some namespaces redefine (shadow) built-in types such as String
and Error
, (catch <type> ...)
now first checks type to see whether it is a symbol that names one of the built-in types (and does not specify a namespace). If so, that type is used, rather than an error resulting.
Support Joker 0.16.0, refactor gostd, update GOSTD.md, etc.
gostd-v0.8 Support Joker 0.16.0, refactor gostd, update GOSTD.md, etc.