home bbs files messages ]

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

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

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

   Message 1,116 of 2,978   
   Marco van de Voort to Markus Humm   
   Re: Problem with array[....] of char   
   14 Nov 04 12:09:48   
   
   From: marcov@stack.nl   
      
   On 2004-11-12, Markus Humm  wrote:   
   > [snip]   
   >>   
   >> The biggest advantage of zero-terminated strings is mainly their ability   
   >> to pass them directly to C. However this works to some extend for Delphi   
   >> strings too.   
   >   
   > But a big disadvantage is the fact that #0 can't be stored in them!   
      
   For C strings: yes,   
      
   delphi ansistrings : no, they can contain #0, but of course when you pass   
   them to the OS that gets lost.   
      
   > And since such beasts are too often misused as buffers of some sort or   
   > the other they are a bad design decision...   
      
   That's AFAIK a historical thing, not abuse. In original K&R C and Unix,   
   _buffers where_ char *, since that was the main 1 byte datatype. This, and   
   the introduction of VOID are the most important differences between K&R and   
   Ansi C. (at least in the context of POSIX, which is where I typically   
   encounter C).   
      
   When those are used as buffers, (just like array of byte or ^ array of byte   
   in Pascal) the zero termination has no meaning.   
      
   (Just some random thought:   
   Strangely enough there is some analogy with J&W and TP too:   
   - Later TPs also introduces a generic pointer type "POINTER".   
   - Later TPs also formalises a string construct, and step away from the   
   	"array of xxx; and everybody does their own thing" system, though   
   	it goes one or two steps further than Ansi C, probably because   
   	of C's conservatism due to the use in Unix.   
   )   
      
   Of course inexperienced people will make a mess, but that is in any   
   language.   
      
   --- 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