Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

cue: support type conversions #3

Closed
mpvl opened this issue Jan 30, 2019 · 7 comments
Closed

cue: support type conversions #3

mpvl opened this issue Jan 30, 2019 · 7 comments
Labels
FeatureRequest New feature or request roadmap/language-changes Specific tag for roadmap issue #339

Comments

@mpvl
Copy link
Contributor

mpvl commented Jan 30, 2019

This is a tracking issue for the implementation of the commented out sections in the spec for conversions.

For instance:

  • convert between the integer types
  • between byte lists and bytes
  • etc

But also to convert a struct to a specific struct type. The latter is quite handy for various purposes.

@mpvl mpvl added the FeatureRequest New feature or request label Jan 30, 2019
@mpvl mpvl changed the title Support type conversions cue: support type conversions Jan 30, 2019
@pavel-khritonenko
Copy link

Want to calculate Sha1 checksum and then encode it into Base64 string, but I'm unable to do that, because:

cannot use [164,124,236,58,150,40,5,40,196,175,13,142,106,236,181,44,17,99,146,48] (type list) as string|bytes in argument 2 to encoding/base64.Encode

@pavel-khritonenko
Copy link

And in that case, the main root that [Size]byte defined as the return type in crypto/* packages is not being treated as bytes.

@mpvl
Copy link
Contributor Author

mpvl commented Sep 3, 2019

It still makes sense to support conversions, but it probably makes sense to interpret [Size]byte as []byte, and not a list of ints in the first place.

This would be a relatively minor, but breaking change, but presumably a welcome one and I think it is worth it. Feedback welcome.

@pavel-khritonenko
Copy link

pavel-khritonenko commented Sep 3, 2019

@mpvl I wondering if there is a working example of crypto/sha1 pkg usage. Cannot imagine where I would like to have [...int] type instead of bytes. I checked all other public packages, only crypto/* packages have such return type.

And it's a definitely different issue than conversion between types.

@mpvl
Copy link
Contributor Author

mpvl commented Sep 3, 2019

I think it is unlikely. We are still in a change where changes can be made if it makes sense (with due consideration of course), but here I think it is obvious.

These APIs were generated before CUE had a bytes type. Now it does, it seems consistent to use it not only for []byte, but also [...]byte.

@mpvl
Copy link
Contributor Author

mpvl commented Sep 3, 2019

I've checked, and such a change in interpretation would only affect the crypto packages.

@mpvl mpvl added the roadmap/language-changes Specific tag for roadmap issue #339 label Dec 1, 2019
@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#3.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

@cueckoo cueckoo closed this as completed Jul 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest New feature or request roadmap/language-changes Specific tag for roadmap issue #339
Projects
None yet
Development

No branches or pull requests

3 participants