From: Nala Ginrut <nalaginrut@gmail.com>
To: Matt Wette <matthew.wette@verizon.net>, guile-user@gnu.org
Subject: Re: [potluck dish] the (potluck struct) module
Date: Sun, 08 May 2016 17:59:29 +0800 [thread overview]
Message-ID: <1462701569.7616.97.camel@gmail.com> (raw)
In-Reply-To: <AD01D09D-343A-4B15-955E-3E56CE0789D8@verizon.net>
Hi Matt!
I'm finding `python pack' stuff, and I found your potluck is very cool!
Could you put it in a git repo somewhere? It would be worth to maintain
or receive patches. And maybe a better module name rather than (potluck
struc)
Thanks!
On Tue, 2016-02-16 at 05:53 -0800, Matt Wette wrote:
> First message got garbled. Redo:
>
> If you have used the Python struct module then this will look
> familiar.
> Otherwise, check out https://docs.python.org/2/library/struct.html
>
> Attached are three files:
> * struct.scm: the source code
> * struct.texi: documentation
> * struct.test: test code
>
> Struct Module
> =============
>
> The '(potluck struct)' module provides procedures for packing and
> unpacking scheme data to and from bytevectors based on a format
> string.
>
> (use-modules (potluck struct))
>
> ;; pack two unsigned shorts and a double float in big endian
> order
> (define data (pack ">2Hd" 3 22 34.0))
> (write data) (newline)
> ==>
> #vu8(0 3 0 22 64 65 0 0 0 0 0 0)
>
> ;; verify using unpack
> (write (unpack ">2Hd" data)) (newline)
> ==>
> (3 22 34.0)
>
> -- Scheme Procedure: pack format vals ...
> Return a bytevector that contains encoded data from VALS, based
> on
> the string FORMAT.
>
> -- Scheme Procedure: unpack format bvec
> Return a list of scheme objects decoded from the bytevector
> BVEC,
> based on the string FORMAT.
>
> -- Scheme Procedure: packed-size format
> Return the number of bytes represented by the string FORMAT.
>
> The _format_ string used for PACK and UNPACK is constructed as a
> sequence of digits, representing a repeat count, and codes,
> representing
> the binary content.
>
> The string may optionally begin with a special character that
> represents
> the endianness:
> = native endianness
> < little-endian
> > big-endian
> ! network order -- i.e., big-endian
>
> Type codes used in the format string are interpreted as follows:
> x blank byte
> c 8-bit character
> ? boolean
> b signed 8-bit integer
> B unsigned 8-bit integer
> h signed 16-bit integer
> H unsigned 16-bit integer
> i signed 32-bit integer
> I unsigned 32-bit integer
> l signed 32-bit integer
> L unsigned 32-bit integer
> q signed 64-bit integer
> Q unsigned 64-bit integer
> f 32-bit IEEE floating point
> d 64-bit IEEE floating point
> s string
>
> The following issues remain to be addressed:
> string padding
> 'pack' assumes that the string length in the format is the same
> as
> in the passed string. Non-conformance is not trapped as an
> error.
>
next prev parent reply other threads:[~2016-05-08 9:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-10 10:23 Potluck time! Ludovic Courtès
2016-02-10 17:35 ` Christopher Allan Webber
2016-02-10 20:17 ` Stefan Israelsson Tampe
2016-02-13 14:36 ` Stefan Israelsson Tampe
2016-02-13 20:32 ` Stefan Israelsson Tampe
2016-02-16 13:28 ` [potluck dish] the module (potluck struct) Matt Wette
2016-02-16 13:30 ` [potluck dish] the module (potluck regexc) Matt Wette
2016-02-16 13:45 ` [potluck dish] the (potluck struct) module Matt Wette
2016-02-16 13:53 ` Matt Wette
2016-05-08 9:59 ` Nala Ginrut [this message]
2016-05-08 14:34 ` Matt Wette
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462701569.7616.97.camel@gmail.com \
--to=nalaginrut@gmail.com \
--cc=guile-user@gnu.org \
--cc=matthew.wette@verizon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).