home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.linux.misc      Linux-specific topics not covered by oth      135,536 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 134,248 of 135,536   
   The Natural Philosopher to John Ames   
   Re: naughty Python   
   02 Jan 26 19:38:30   
   
   XPost: alt.folklore.computers   
   From: tnp@invalid.invalid   
      
   On 02/01/2026 16:49, John Ames wrote:   
   > On Fri, 2 Jan 2026 10:59:55 +0000   
   > The Natural Philosopher  wrote:   
   >   
   >>> If you really needed 100 variant record in Turbo Pascal,   
   >>> then you needed 100 unions in C.   
   >>   
   >> No. You simply used *casting* .   
   >>   
   >> k=*(int *)(buffer +4) etc etc.   
   >   
   > You do have to be careful with this as it's not guaranteed that the   
   > compiler won't take liberties in arranging members of a struct for   
   > optimization purposes, and any means to ensure that it doesn't are   
   > implementation-specific, so assumptions about casting a block of memory   
   > to one struct/array or another can lead to portability issues...   
   >   
   > ...but boy, is it handy in a pinch!   
   >   
   Indeed. Fortunately this was in the days before smart compilers.   
   I think I had the DR 8086 C compiler to work with .   
      
      
   --   
   "Anyone who believes that the laws of physics are mere social   
   conventions is invited to try transgressing those conventions from the   
   windows of my apartment. (I live on the twenty-first floor.) "   
      
   Alan Sokal   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca