Re: gets() and "string" variable type
- Posted by Pete Lomax <petelomax at blue?onder.co?uk> Sep 15, 2007
- 595 views
Andy Drummond wrote: > > What I would like to see addressed too is the possibility > of a type "string", which is a string of bytes rather than > a sequence of 32-bit words. The memory saving is significant, > and the possibility of strings containing non-characters is > completely removed. > > So - comments? The s[i] op is of critical importance, which I now know from practical experience, and supporting both 8-bit strings and 4-byte sequences would inevitably lead to an overhead of about 20%. Still want? Regards, Pete PS [OT] Can someone explain the last line of this snippet from be_execute.e: case L_RHS_SUBS_CHECK: if (!IS_SEQUENCE(*(object_ptr)pc[1])) { goto subsfail; } /* FALL THROUGH */ case L_RHS_SUBS: /* rhs subscript of a sequence */ top = *(object_ptr)pc[2]; /* the subscript */ obj_ptr = (object_ptr)SEQ_PTR(*(object_ptr)pc[1]);/* the sequence */ if ((unsigned long)(top-1) >= ((s1_ptr)obj_ptr)->length) { tpc = pc; top = recover_rhs_subscript(top, (s1_ptr)obj_ptr); } top = (object)*(top + ((s1_ptr)obj_ptr)->base); My grasp of C is limited and I do not actually understand how it knows to get "top" from "base+top*4" rather than just "base+top". Not that it does not seem logical, more "how does it know?" Specifically, which parts of typedef long object; typedef object *object_ptr; are applied/applicable when and where? Is it the earlier *(object_ptr) or the latter (object)* or both or what?