Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.os.development    |    Operating system development chatter    |    4,255 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 2,773 of 4,255    |
|    mutazilah@gmail.com to Rod Pemberton    |
|    Re: microsoft vs linux    |
|    07 Aug 21 12:43:44    |
   
   From: muta...@gmail.com   
      
   On Thursday, July 22, 2021 at 12:44:47 PM UTC+10, Rod Pemberton wrote:   
      
   > > >> I can't think why you might want multiple levels of software all   
   > > >> to have the same name. I'm not arguing that you should do   
   > > >> otherwise. That's your choice. But it does seem unnecessary and   
   > > >> confusing.   
   > > >   
   > > > I think it's very neat. If you want to write 1 byte to a   
   > > > FAT partition at offset 372, you can use fseek and   
   > > > fputc, rather than fwrite.   
   > >   
   > > On the face of it I cannot see from that why you would want multiple   
   > > functions all to be called fwrite.   
   > >   
   > What? ...   
   >   
   > Clearly, "multiple functions all to be called [the exact same thing]" is   
   > a concise statement of the fundamental concept of overloading from   
   > object-oriented programming languages.   
      
   I'm thinking that it is time for me to introduce "overloading"   
   into my C programming style.   
      
   First of all, I wish to limit hard disks to 2 GiB, at least for   
   32-bit programming.   
      
   And to change zap the MBR to set a partition active, I'm   
   expecting to do something like:   
      
   disk80 = fopen("0x80", "r+b"); /* disk 80 is first hard disk */   
   fseek(disk80, 0x7c); /* 7c is just an example - didn't look up the right value   
   for first partition status byte */   
   fputc(0x3, disk80); /* 0x3 is just an example - didn't look up the right value   
   for partition = active */   
      
   I expect that when the fputc() is executed, it will result in a   
   BosDiskSectorRLBA() to read a single sector (sector 0 in   
   fact) followed by BosDiskSectorWLBA() to write it back.   
      
   But I was wondering if there was a possibility of having:   
      
   typedef struct {   
   size_t (*fwrite)(FILE * or BIOS *)   
   } BIOS;   
      
   size_t bios_fwrite(FILE * or BIOS *)   
   {   
   }   
      
   BIOS *bios;   
      
   bios->fwrite = bios_fwrite;   
      
   bios->fwrite();   
      
   This would allow the exact name (fwrite) to be used in all   
   code, even though I will necessarily need to distinguish   
   between bios_fwrite() and fat_fwrite() etc to avoid name   
   clashes at link time.   
      
   Maybe these names would be much cleaner than the C++   
   auto-generated mangled names.   
      
   But I don't really know what I'm doing. It's all muddled.   
      
   BFN. Paul.   
      
   --- 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