Fork me on GitHub
#joker
<
2021-04-01
>
jcburley07:04:38

https://github.com/jcburley/joker/releases/tag/gostd-v0.10  https://github.com/jcburley released this 2 minutes ago · https://github.com/jcburley/joker/compare/gostd-v0.10...gostd to gostd since this release 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. `http://go.std.net/FlagUp` is of type `net.Flags`, not `Number`, so this now works (as `http://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=> 
up
user=> (int )
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.

jcburley16:04:44

@U75LX44UA: if you find some time, please review the changes to how BigFloats are handled, and let me know what you think and whether you want me to do up a crossport PR for official Joker. Specifically: MakeBigFloat* are new APIs, and the WithOrig() one is now used by read.go for arbitrary-precision constants (ending in M); instead of setting precision to a constant 256, they compute the precision based on the number and “width” of digits in the constant (minimum being 53, the precision for a float64 aka Double); and a new core function precision returns the precision info (and I’m happy to create a set-precision that’d work on BigFloat if there’s any interest).

Candid17:04:26

Hey @U7W1AJ761 , can you post this as a github issue? On vacation right now, not sure when I’ll get to looking into this.

👍 3
jcburley17:04:09

What a coincidence: we’re on vacation too this week (in Avon, CO)! Between weather and other stuff, I’m finding plenty of “down time” to just hack away on Joker, as often happens on vacation…. Enjoy!

Candid17:04:40

You too!

👍 3
jcburley07:04:38

https://github.com/jcburley/joker/releases/tag/gostd-v0.10  https://github.com/jcburley released this 2 minutes ago · https://github.com/jcburley/joker/compare/gostd-v0.10...gostd to gostd since this release 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. `http://go.std.net/FlagUp` is of type `net.Flags`, not `Number`, so this now works (as `http://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=> 
up
user=> (int )
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.