Implementation-DEPENDENT code (was:strcpy)

Stan Switzer sjs at spectral.ctt.bellcore.com
Tue Apr 12 00:52:51 AEST 1988


This point bears repeating:

> In article <4331 at ihlpf.ATT.COM> nevin1 at ihlpf.ATT.COM (00704a-Liber) writes:
> >The reason that I do not like the proposed change
> [to the proposed dpANS to make strcpy(s,s+n) defined]
> >is because it ENCOURAGES implementation-dependent code, which, to
> >put it simply, is a *bad* programming paradigm.
  
In article <10969 at mimsy.UUCP> chris at mimsy.UUCP writes:
> Once again, IF THE CHANGE WERE MADE, IT WOULD NOT BE IMPLEMENTATION
> DEPENDENT.

Thanks, Chris, for a few sane words.

I think a few observations can be made about this "tempest-in-a-teapot"

  1) Some (most, possibly all) implementations DO implement strcpy
     left-to-right.   (prior-art)
  2) It is (occasionally) a useful thing to guarantee.  (useful feature)
  3) There is a body of code which uses this feature.  (do not break
     existing code)
  4) There has been NO example presented where any other order of copying
     would yield faster code.  (efficiency, spirit-of-C)

Perhaps the Committee has forgotton its charter?

Stan Switzer



More information about the Comp.lang.c mailing list