home bbs files messages ]

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

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

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

   Message 242,097 of 243,242   
   Kaz Kylheku to olcott   
   Re: DD simulated by HHH and DD simulated   
   24 Nov 25 16:32:01   
   
   XPost: comp.theory, comp.lang.c++   
   From: 643-408-1753@kylheku.com   
      
   On 2025-11-24, olcott  wrote:   
   > On 11/22/2025 11:24 PM, Kaz Kylheku wrote:   
   >> That's just the thing! If this were correctly implemented then in fact   
   >> DD /wold be/ calling HHH1, using the name HHH.   
   >>   
   >   
   > You are trying to get away with this lie   
   > about the semantics of C?   
   >   
   > int main()   
   > {   
   >    HHH(DD);   
   >    HHH1(DD);   
   >    return 0;   
   > }   
   >   
   > _main()   
   > [000022c4] 55             push ebp   
   > [000022c5] 8bec           mov ebp,esp   
   > [000022c7] 6834220000     push 00002234 ; push DD   
   > [000022cc] e833f3ffff     call 00001604 ; call HHH   
   > [000022d1] 83c404         add esp,+04   
   > [000022d4] 6834220000     push 00002234 ; push DD   
   > [000022d9] e856f2ffff     call 00001534 ; call HHH1   
   > [000022de] 83c404         add esp,+04   
   > [000022e1] 33c0           xor eax,eax   
   > [000022e3] 5d             pop ebp   
   > [000022e4] c3             ret   
   > Size in bytes:(0033) [000022e4]   
      
   That's right; even if HHH and HHH1 are separately realized and given   
   different adddresses, not recognized as identical by the compiler and   
   not folded into one copy, in a correct implementation of your software,   
   HHH(DD) and HHH1(DD) would behave as indistinguishable, mutually   
   interchangeable operations.   
      
   The problem is that you have logic which concludes that HHH1 != HHH (low   
   level pointer comparison), they are different functions.   
      
   If it helps, you can think about it by analogy to strings. Suppose   
   you had code:   
      
     puts("Hello"):   
     puts("Hello"):   
      
   and suppose that the compiler did not fold the two strings to one   
   object (maybe it does that, but optimization is turned off). Suppose   
   you see this code:   
      
      push 0001230 ; push "Hello"   
      call 0432180 ; call puts   
      push 0001240 ; push "Hello"   
      call 0432180 ; call puts   
      
   Do you conclude form that that "Hello" and "Hello" are different   
   strings, so that your program is correct in using str! != str2   
   for string comparison?   
      
   Think about the differences between:   
      
   - pointer equivalence   
      
   - strng equivalence   
      
   - procedure equvalence   
      
   --   
   TXR Programming Language: http://nongnu.org/txr   
   Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal   
   Mastodon: @Kazinator@mstdn.ca   
      
   --- 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