Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's unclear what types Resolve(...) can return. #25

Open
Stebalien opened this issue Aug 17, 2017 · 4 comments
Open

It's unclear what types Resolve(...) can return. #25

Stebalien opened this issue Aug 17, 2017 · 4 comments

Comments

@Stebalien
Copy link
Member

For example, let's say that I'm expecting a number. Should I try casting to a uint64?, float?, etc. We should either provide "canonical" types aliases:

type Integer uint64
type String string
// ...

Or return a custom type:

type Value interface{}

func (v Value) Int() uint64, error {}
func (v Value) String() string, error {}
func (v Value) Nil() error {}
@whyrusleeping
Copy link
Member

We can't know what it returns though. It can return literally anything.

@Stebalien
Copy link
Member Author

It can't, e.g., return a peer.ID, can it? That is, I assume it can only return primitives. The problem is that it's unclear what primitives it can return. See the example in the issue body; CBOR, e.g., encodes integers as varints but nothing indicates if go-ipld-cbor can return int, int32, int64, BigInt, float32, or all of the above.

Basically, we need consistent set of primitive types.

@whyrusleeping
Copy link
Member

whyrusleeping commented Sep 2, 2017 via email

@Kubuxu
Copy link
Member

Kubuxu commented Sep 3, 2017

CBOR also can encode either floating point or normal integers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants