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

bytes method in numerical types? #4796

Open
p6rt opened this issue Nov 29, 2015 · 4 comments
Open

bytes method in numerical types? #4796

p6rt opened this issue Nov 29, 2015 · 4 comments
Labels
RFC Request For Comments

Comments

@p6rt
Copy link

p6rt commented Nov 29, 2015

Migrated from rt.perl.org#126758 (status was 'open')

Searchable as RT126758$

@p6rt
Copy link
Author

p6rt commented Nov 29, 2015

From tkook11@gmail.com

This would add a .bytes method (or similarly-named) that returns a Blob containing the Numeric's data. This would be the natural representation of the Numeric, and would take an optional parameter specifying endianness (should it be ignored for Num or give an error?)

This would be useful in serializing data (to write to a file or a socket).

A reverse method would be useful as well.

@p6rt
Copy link
Author

p6rt commented Nov 30, 2015

From @ShimmerFairy

On Sat Nov 28 20​:02​:17 2015, tkook11@​gmail.com wrote​:

This would add a .bytes method (or similarly-named) that returns a
Blob containing the Numeric's data. This would be the natural
representation of the Numeric, and would take an optional parameter
specifying endianness (should it be ignored for Num or give an error?)

This would be useful in serializing data (to write to a file or a
socket).

A reverse method would be useful as well.

This ties into the larger question on how to handle the parsing and output of binary data, something we most likely won't figure out in time for Christmas. So I don't think it'd be a good idea to add just this feature in isolation.

However, please feel free to develop some kind of module that can serialize and deserialize binary data (you can even add methods to existing classes using 'augment', if you wish). You can also go around to places such as the Perl 6 IRC channel and discuss how to go about binary data handling.

Simply put, I think at this point we'd do well to have an external module for prototyping binary data handling, and use that to figure out how we would like to do it in a future version of Perl 6 :) .

(One final hint​: some kind of serialization method would have to be defined for each numeric type, and not just on Numeric, since things like Complex or Rat or Int or Num would each need special handling.)

@p6rt
Copy link
Author

p6rt commented Nov 30, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Nov 30, 2015

From tkook11@gmail.com

On Sun Nov 29 19​:04​:30 2015, lue wrote​:

On Sat Nov 28 20​:02​:17 2015, tkook11@​gmail.com wrote​:

This would add a .bytes method (or similarly-named) that returns a
Blob containing the Numeric's data. This would be the natural
representation of the Numeric, and would take an optional parameter
specifying endianness (should it be ignored for Num or give an
error?)

This would be useful in serializing data (to write to a file or a
socket).

A reverse method would be useful as well.

This ties into the larger question on how to handle the parsing and
output of binary data, something we most likely won't figure out in
time for Christmas. So I don't think it'd be a good idea to add just
this feature in isolation.

However, please feel free to develop some kind of module that can
serialize and deserialize binary data (you can even add methods to
existing classes using 'augment', if you wish). You can also go around
to places such as the Perl 6 IRC channel and discuss how to go about
binary data handling.

Simply put, I think at this point we'd do well to have an external
module for prototyping binary data handling, and use that to figure
out how we would like to do it in a future version of Perl 6 :) .

(One final hint​: some kind of serialization method would have to be
defined for each numeric type, and not just on Numeric, since things
like Complex or Rat or Int or Num would each need special handling.)

The hypothetical .bytes method would contain only the raw data, without the type info. I was also thinking about a separate method, though, perhaps named .serialize, which contains type info as well as working on all types.

@p6rt p6rt added the RFC Request For Comments label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request For Comments
Projects
None yet
Development

No branches or pull requests

1 participant