-
Notifications
You must be signed in to change notification settings - Fork 16
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
use experimental :pack
should be removed
#442
Comments
Case in point:
|
The The Net::AMQP is quite a heavy user of pack/unpack so will need a rework but that isn't a showstopper with sufficient warning. But IIRC |
Yeah, "modules of a certain age" 😺 |
I thought that |
FWIW some of the examples above ☝️ probably don't even need that. The
(and no other uses of the Which is basically:
Or something. |
The
Which is basically :
|
Which makes one wonder whether |
As an additional comment: P5pack should probably get a complete makeover building code with RakuAST, similar to |
use experimental :pack
should be removed
In my experience (implementing binary protocols), this general problem area is not well solved right now. |
@Leont Could P5pack serve as an "nqp" in your opinion for such a module? |
What did/do you make of @alabamenhu's Binex? (Iirc they paused their work on it until RakuAST had sufficiently matured and Rakoons were sufficiently interested in there being a better solution in this space. Or perhaps they came up with another solution; if so I guess it would be good to hear from them what that was.) |
No, I think that's wiring things exactly the wrong way around. Though I do think RakuAST is the right way to go about these things. |
I doesn't look like it's a good solution for my problem. Binary formats don't generally involve things like backtracking, I don't think regexes are quite the paradigm. What I really want that pack doesn't offer includes:
Ideally it would also be usable with streams instead of bufs, but that may be a little too ambitious for now. |
@Leont feels to me you're advocating a superset of the functionality |
Are you thinking along the lines of: a format eating N bytes from a stream, then N again, and exposing that as a Supply ? |
Personally, I have always felt pack/unpack to be a bit of an anachronism in a language with (native) types. When I needed something to inspect MoarVM's bytecode files I therefore just wrote this little ByteReader that inspects struct like types to figure out what to read: https://gist.github.com/niner/63a718023aba72e0dffc39c1ccd84e32 It's very little code that lets me declare structs as simple classes with natively typed members and let's me read those structs via e.g. |
Also |
Yes, possibly something of a high level AST even (I mean, the problem involves both loops,conditionals and state). Something like
Yeah something like that, except it wouldn't quite be a fixed number of bytes. |
A format eating the bytes from a stream that it needs, and again, exposing that as a Supply :-) |
Yep. This was part of the conversation when Part of the problem is that a lot of the binary data that is in the wild is either in a format that seemed natural in the language that it was originally implemented in (probably extinct,) or seemed natural for the application and was specified in a way that could be easily implemented in any relatively low level language available at the time without the kind of abstractions we are used to. The former includes stuff like COBOL |
Yeah, |
In the simple (static,) case this could work well with, say, some role to allow for construction from a Blob and some traits to specify the translation to Raku typed attributes. But in the dynamic case where the structure of subsequent data is dependent on earlier values then we're going into DSL territory rather than something that can be simply declarative. A relatively simple example of the more complex case might be a dBase |
So when I'm done, you should be able to do most of this stuff. I didn't really imagine Binex with backtracking in mind -- when I use grammars, I'm almost always using tokens as most common formats are generally designed carefully to avoid needing any kind of backtracking. But I did imagine being able to do basically everything you've pointed up there except for encoding (which I figured would just pass a blob to a decode during the action phase). As raiph pointed out, though, I did hold off on developing it further. I think RakuAST is sufficiently mature I could get back to it, though. But it doesn't really create an equivalent pack equivalent, so it probably wouldn't fit your use case. |
The P5pack module covers most of the functionality needed.
And the
use experimental :pack
functionality has bugs: rakudo/rakudo#1875The text was updated successfully, but these errors were encountered: