Why is `scope` planned for deprecation?
Paulo Pinto via Digitalmars-d
digitalmars-d at puremagic.com
Mon Nov 17 05:39:04 PST 2014
On Monday, 17 November 2014 at 12:49:16 UTC, Ola Fosheim Grøstad
wrote:
> On Monday, 17 November 2014 at 12:36:49 UTC, Paulo Pinto wrote:
>> On Monday, 17 November 2014 at 11:43:45 UTC, Ola Fosheim
>> Grøstad wrote:
>>> Remember that the alternative to zero-terminated strings at
>>> that time was to have 2 string types, one with a one byte
>>> length and one with a larger length. So I think C made the
>>> right choice for it's time, to have a single string type
>>> without a length.
>>
>> Black hat hackers, virus and security tools vendors around the
>> world rejoice of that decision...
>>
>> It was anything but right.
>
> I don't think buffer overflow and string fundamentals are
> closely related, if used reasonably, but I'm not surprised you
> favour Pascal's solution of having two string types: one for
> strings up to 255 bytes and another one for longer strings.
>
> Anyway, here is the real reason for how C implemented strings:
>
> «None of BCPL, B, or C supports character data strongly in the
> language; each treats strings much like vectors of integers and
> supplements general rules by a few conventions. In both BCPL
> and B a string literal denotes the address of a static area
> initialized with the characters of the string, packed into
> cells. In BCPL, the first packed byte contains the number of
> characters in the string; in B, there is no count and strings
> are terminated by a special character, which B spelled `*e'.
> This change was made partially to avoid the limitation on the
> length of a string caused by holding the count in an 8- or
> 9-bit slot, and partly because maintaining the count seemed, in
> our experience, less convenient than using a terminator.
>
> Individual characters in a BCPL string were usually manipulated
> by spreading the string out into another array, one character
> per cell, and then repacking it later; B provided corresponding
> routines, but people more often used other library functions
> that accessed or replaced individual characters in a string.»
>
> http://cm.bell-labs.com/cm/cs/who/dmr/chist.html
I am fully aware how UNIX designers decided to ignore the systems
programming being done in Algol variants, PL/I variants and many
other wannabe systems programming languages that came before C.
Which they are repeating again with Go.
--
Paulo
More information about the Digitalmars-d
mailing list