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
Musing about possible small scale Raku projects just to help myself get back into the swing of things, I began to wonder what it would take implement an alternate character encoding in Raku. I figured it would be an interesting if likely slightly nostalgic learning exercise. For context, I was tossing implementing an old IBM code page or two or maybe Baudot code and round tripping it (if possible) with Unicode.
I started to dig through the the documentation but found it less than awesome...
The docs mention Encoding::Registry and its .register method, but there were no examples. There were also references to Encoding::Encoder and Encoding::Decoder but not a lot of details.
So, I started digging through the Rakudo and MoarVM source to try to figure out what the docs weren't telling me. What I've been able to determine so far is:
Encoding::Registry implements an NQP list of encodings that agrees with an identical list in MoarVM. Presumably, these are implemented in C under MoarVM's hood.
Encoding::Encoder has a method with a signature encode-chars(Str:D --> Blob:D) but the implementation is yada, yada, yada'd { ... }
The Encoding::Decoder isn't much different: a bunch of methods with signatures and yada, yada, yada operator.
I infer that I'm supposed to do something with the existing roles to extend them, but I'm not sure how that's supposed to work. I'm even more unsure how multiple custom encodings would work without stepping on each other. I'm absolutely running up against my knowledge limits with Raku as I don't really understand how roles differ from objects. I've read the Roles documentation in starts and stops and I confess I'm not connecting all of the dots.
Insights and comments are welcome. Forgive me if all of this is blindingly obvious to the rest of the group. This might make for interesting conversation at the next meeting.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Musing about possible small scale Raku projects just to help myself get back into the swing of things, I began to wonder what it would take implement an alternate character encoding in Raku. I figured it would be an interesting if likely slightly nostalgic learning exercise. For context, I was tossing implementing an old IBM code page or two or maybe Baudot code and round tripping it (if possible) with Unicode.
I started to dig through the the documentation but found it less than awesome...
The docs mention
Encoding::Registry
and its.register
method, but there were no examples. There were also references toEncoding::Encoder
andEncoding::Decoder
but not a lot of details.So, I started digging through the Rakudo and MoarVM source to try to figure out what the docs weren't telling me. What I've been able to determine so far is:
Encoding::Registry
implements an NQP list of encodings that agrees with an identical list in MoarVM. Presumably, these are implemented in C under MoarVM's hood.Encoding::Encoder
has a method with a signatureencode-chars(Str:D --> Blob:D)
but the implementation is yada, yada, yada'd{ ... }
Encoding::Decoder
isn't much different: a bunch of methods with signatures and yada, yada, yada operator.I infer that I'm supposed to do something with the existing roles to extend them, but I'm not sure how that's supposed to work. I'm even more unsure how multiple custom encodings would work without stepping on each other. I'm absolutely running up against my knowledge limits with Raku as I don't really understand how roles differ from objects. I've read the Roles documentation in starts and stops and I confess I'm not connecting all of the dots.
Insights and comments are welcome. Forgive me if all of this is blindingly obvious to the rest of the group. This might make for interesting conversation at the next meeting.
Beta Was this translation helpful? Give feedback.
All reactions