google / blockly-samples

Plugins, codelabs, and examples related to the Blockly library.
http://github.com/google/blockly
Apache License 2.0
833 stars 618 forks source link

bit<>char<>float conversion #341

Open bladedsupernova opened 4 years ago

bladedsupernova commented 4 years ago

My projects often deal with text prediction / compression. Meaning I need to predict the next bit of the sentence. The "code" made during this is a long number and also needs to be made into a binary form to store the super long number. So there's a constant need to transform bytes to bits and back. I also find integer/float to text conversion commonly needed, and conversion back to integer/float too. These last steps in my project resulted in me having to finish the code in Python editor, instead of being fully shareable as blocks.

I see the create_text_with block can transform a number into a string type. It would be very useful to have such other similar block that convert string/integer(/float)/bit types to and from each other.

Perhaps you could create a switch for just Python if it won't work for all 5 languages.

moniika commented 4 years ago

Typing is a tricky business, but a block to convert types sounds like it could be an interesting/useful feature. As you mentioned, it wouldn't work for all 5 languages and I doing think it would be a commonly used block. For that reason, I don't think it would fit in Blockly core, but it could be an interesting candidate to add to Blockly Samples. We are still working out our strategy for contributing and the releasing to Blockly Samples, so I wouldn't expect us to address this in the near future. You could try to implement a custom block yourself in the meantime.