You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
As per the initial comment on #21 I noticed that Decode will not handle quite a few common cases where there may need to be some basic coercions.
Of particular note in reference to #21 is the fact that a nil in any value coming from mruby will fail at one of the unknown type checks.
For nil specifically I think that using zero types would be most appropriate.
But there are additional cases that it would be nice to handle for completeness.
Some examples:
decodeString doesn't handle floats or boolean
decodeFloat doesn't handle fixnum
decodeInt doesn't handle float (not sure if we should handle this given information loss)
Nothing handles nil
I propose a table of coercions is produced on this issue and an implementation can stem from that.
The text was updated successfully, but these errors were encountered:
Here is a first (fairly arbitrary) stab aiming to keep it simple.
Horizontal types are ruby
Vertical types are golang
Array / map conversions will follow key / value type conversion rules for each element. (e.g. map[string]float would follow string conversion rules for keys and float conversion rules for values).
Structs, user types & enums are not covered due to potential complexity of mapping.
I'm not sure if float -> int should be allowed due to precision loss. Dynamic languages typically allow this though.
It's also quite strict and does not allow (for instance) Fixnum -> bool conversion.
TrueClass
FalseClass
NilClass
String
Fixnum
Bignum
Float
Range
Array
Hash
Symbol
Float
invalid
invalid
ZeroType
atof
FloatValue
FloatValue
FloatValue
invalid
invalid
invalid
invalid
String
"true"
"false"
ZeroType
StringValue
StringValue
StringValue
StringValue
invalid
invalid
invalid
StringValue
Array
invalid
invalid
ZeroType
invalid
invalid
invalid
invalid
per-elem
per-elem
invalid
invalid
Map
invalid
invalid
ZeroType
invalid
invalid
invalid
invalid
invalid
invalid
per-elem
invalid
Int
invalid
invalid
ZeroType
atoi
IntValue
IntValue
?
invalid
invalid
per-elem
invalid
Bool
true
false
ZeroType
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
Due to the breadth of work implementing this will require I will await feedback before proceeding.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
As per the initial comment on #21 I noticed that
Decode
will not handle quite a few common cases where there may need to be some basic coercions.Of particular note in reference to #21 is the fact that a
nil
in any value coming from mruby will fail at one of theunknown type
checks.For
nil
specifically I think that using zero types would be most appropriate.But there are additional cases that it would be nice to handle for completeness.
Some examples:
I propose a table of coercions is produced on this issue and an implementation can stem from that.
The text was updated successfully, but these errors were encountered: