In article <2024Mar11.220843@mips.complang.tuwien.ac.at>,   
   Anton Ertl wrote:   
   >Paul Rubin writes:   
   >Java also has null pointers, another possible mistake. Ada doesn't have   
   >>them,   
   >   
   >Ada certainly has null.   
   >   
   >>C++ has them because of its C heritage and   
   >>the need to support legacy code, but I believe that in "modern" C++   
   >>style you're supposed to use references instead of pointers, so you   
   >>can't have a null or uninitialized one.   
   >   
   >I don't know much about C++, but I would be surprised if they had   
   >given up on uninitialized data. And an uninitialized reference is   
   >certainly not better than a null reference.   
      
   I can't see the problem with null pointers. Algol68 had an explicit   
   `nil' that serves the same purpose. Any reference is initialized with   
   `nil'. If you try to dereference it, meaning trying to fetch or otherwise   
   use the referred object this meets with a run time error.   
   That is probably the clean and expensive way.   
   So nil + reference takes the same place as NULL + pointer in c.   
      
   I try to emulate this in ciforth. Looking up a word in the dictionary   
   results in an entry (struct with fields for properties) or a null pointer,   
   i.e. zero. You are supposed to test for this case, but if you fail   
   you get a "Segmentation fault".   
   As far as Forth goes, that is pretty satisfactory security.   
      
      
   >   
   >- anton   
      
   Groetjes Albert   
   --   
   Don't praise the day before the evening. One swallow doesn't make spring.   
   You must not say "hey" before you have crossed the bridge. Don't sell the   
   hide of the bear until you shot it. Better one bird in the hand than ten in   
   the air. First gain is a cat purring. - the Wise from Antrim -   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|