On 13/12/2013, at 2:12 AM, srean wrote:

> 
> I see, but in that case why dont people use a pointer and a length. Given how 
> widely this style of code is used, wondering if there is anything that this 
> provides that is not provided by a pointer and a length. 

Instead of:

        struct Str {
                int len;
                char data[1];
        };

        Str *p = ....

        p->len ...
        p->data[i] ...


you can certainly do:

        unsigned char *buffer;
        int len = *(int *)(void*)buffer;
        char *first = (char*) (void*)(buffer + sizeof(int));

but I hope you see the first solution is more readable. Now consider
this is JUST a simple example with length and an array and consider
a more complex example with many fields.

Consider the second method is more or less writing assembler,
doing all your own address calculations, instead of using the language
to do those calculations for you.

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to