Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #26596

Re: packed structs

From JohnF <john@forkosh.com.com>
Newsgroups comp.lang.c
Subject Re: packed structs
Date 2012-09-23 00:19 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <k3lkhr$85u$1@reader1.panix.com> (permalink)
References (1 earlier) <k3jaun$8al$1@dont-email.me> <e5a6fdcf-0343-4ea9-bfa8-5464c8d355a4@ib4g2000vbb.googlegroups.com> <k3jua2$l2e$1@reader1.panix.com> <slrnk5ri4f.1d3.grahn+nntp@frailea.sa.invalid> <lnobkxu6mx.fsf@nuthaus.mib.org>

Show all headers | View raw


Keith Thompson <kst-u@mib.org> wrote:
> Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
> [...]
>> Didn't read very carefully, but it's like the Python 'struct' module,
>> isn't it?
>>
>>  http://docs.python.org/library/struct.html
> 
> It's also reminiscent of Perl's built-in "pack" and "unpack" functions.
>   http://perldoc.perl.org/functions/pack.html
>   http://perldoc.perl.org/functions/unpack.html

Thanks, Keith (and Jorgen again), that's also incredibly useful.
Lots of food for thought to spec out a C variant. And yet another
format/template to peruse. I really should put some effort into
learning these "little languages".
   Despite BartC's remark, "The main problem Python has to deal
with is that the language doesn't have structs", I think this
kind of pack function has valuable uses in C (along with a
scan-like unpack, as suggested by BartC's other remark),
e.g., formatting (and reading) binary blocks/packets/whatever,
which is what brought the idea to my mind. And the fact that
all these little languages have pack/unpack just supports
the notion they're useful funcs. Moreover, I'm sure you can
see they're no great big deal to code. So why not do it
(I'm in the process, but that's no reason others shouldn't
do it differently/better/whatever)? The naysayers can just
ignore it. I'm sure everybody has their favorite C feature
they choose not to use.
   Finally, regarding Ian's remarks, pack/unpack would be
a >>lightweight<< alternative to accomplish this kind of
task. Ian's way involves importing additional tool dependencies,
possibly turning what could be just a few lines of code
into a subtask unto itself. For his large project case,
involving lots and lots of different block formats,
that may be the best approach (I've worked with Swift
at Bankers Trust, albeit a while back, and also with various
ticker feeds, etc, etc, and more etc). But that's no reason
not to have a lightweight alternative.
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-22 01:54 +0000
  Re: packed structs Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-21 23:22 -0400
    Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-22 06:37 +0000
      Re: packed structs "BartC" <bc@freeuk.com> - 2012-09-22 13:47 +0100
        Re: packed structs Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-22 14:00 +0100
        Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-22 15:42 +0000
      Re: packed structs Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-22 09:13 -0400
      Re: packed structs Johann Klammer <klammerj@NOSPAM.a1.net> - 2012-09-23 03:10 +0200
        Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-23 02:10 +0000
      Re: packed structs Stephen Sprunk <stephen@sprunk.org> - 2012-09-23 11:44 -0500
        Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-23 23:23 +0000
          Re: packed structs Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-24 01:59 +0100
            Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-24 02:54 +0000
              Re: packed structs Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-24 04:38 +0100
                Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-24 04:07 +0000
                Re: packed structs Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-24 12:16 +0100
                Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-24 11:45 +0000
              Re: packed structs "BartC" <bc@freeuk.com> - 2012-09-24 10:18 +0100
                Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-24 11:04 +0000
                Re: packed structs Stephen Sprunk <stephen@sprunk.org> - 2012-09-30 14:21 -0500
                Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-10-01 07:34 +0000
          Re: packed structs Stephen Sprunk <stephen@sprunk.org> - 2012-09-30 13:52 -0500
    Re: packed structs Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-09-22 01:31 -0700
      Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-22 08:53 +0000
        Re: packed structs Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-09-22 14:17 +0000
          Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-22 15:33 +0000
            Re: packed structs Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-09-22 20:43 +0000
            Re: packed structs "BartC" <bc@freeuk.com> - 2012-09-22 22:52 +0100
          Re: packed structs Keith Thompson <kst-u@mib.org> - 2012-09-22 13:47 -0700
            Re: packed structs JohnF <john@forkosh.com.com> - 2012-09-23 00:19 +0000
              Re: packed structs Ian Collins <ian-news@hotmail.com> - 2012-09-23 13:32 +1200
                Re: packed structs JohnF <john@please.see.sig.for.email.com> - 2012-09-23 02:16 +0000
        Re: packed structs Ian Collins <ian-news@hotmail.com> - 2012-09-23 10:33 +1200
          Re: packed structs Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-09-23 01:38 -0700
  Re: packed structs The Great Firewall of China Blue <chine.bleu@yahoo.com> - 2012-09-21 21:29 -0700

csiph-web