Re: Opinion) Overuse of symbolic constants

From: Keith Thompson (kst-u_at_mib.org)
Date: 04/23/04


Date: Fri, 23 Apr 2004 20:39:37 GMT

Dan.Pop@cern.ch (Dan Pop) writes:
> In <4088dfdb.2080231948@news.individual.net>
> rlb@hoekstra-uitgeverij.nl (Richard Bos) writes:
> >mwojcik@newsguy.com (Michael Wojcik) wrote:
> >> In article <c667e8$qok$3@sunnews.cern.ch>, Dan.Pop@cern.ch (Dan
> >> Pop) writes:
> >> > In <Pine.GSO.4.58.0404211032530.12417@drj.pf>
> >> > darrell@NOMORESPAMcs.utoronto.ca.com (Darrell Grainger) writes:
> >> > >However, the SLASH might have a place. I have seen code like:
> >> > >
> >> > >#ifdef WINDOWS
> >> > >#define SEPERATOR '\\'
> >> > >#else
> >> > >#define SEPERATOR '/'
> >> > >#endif
> >> >
> >> > It was probably written by someone ignoring both English and Windows.
> >> >
> >> > In most contexts, Windows accepts the forward slash as path separator.
> >>
> >> Which means that in Windows, you can generally use the forward slash
> >> when generating paths, so there's no need for the macro;
> >
> >You both forget something. Windows _functions_ may be able to understand
> >forward slashes; but Windows _users_ are, in most cases, incapable of
> >comprehending that the backslash is not a god[1]-given holy marking.
> >Ditto, but less so, under Unix. Thus, for human-readable output, you
> >must use the system-sanctified species of slash.
>
> In portable code, the file names are specified by the user. If the user
> gets confused by his own input, there is very little the programmer can
> do...

If the file names are specified by the user, the issue doesn't arise;
re-displaying whatever the user provided is entirely reasonable.
(Mapping the user's input to a more canonical form may or may not be
reasonable; it depends on the circumstances.)

Obviously we're talking about non-portable code with file names
provided or constructed by the program. In that context, it makes
sense to use something that's not going to confuse the user; under
Windows, that means using '\\' rather than '/' as the path separator.
It may not matter if the program never shows any file names to the
user, but a future version of the program may do so even if the
current one doesn't -- or a future version may try to pass a file name
to the command interpreter. (Or there might be some other obscure
circumstances in Windows where '/' and '\\' are not equivalent as path
separators; I'm not assuming there are, but I wouldn't bet against
it.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"


Relevant Pages

  • Re: Spyware/viruses sent through e-mail?
    ... I downloaded a security update from Windows pior to my ... Sorry to confuse you, I did not mean to imply that your PC was infected ... A friend of the wife's has a husband that refuses to stop going to porn ... different spyware packages, everywhere. ...
    (microsoft.public.windowsxp.general)
  • Re: fgets() equivalent?
    ... and doesn't confuse Excel, so I'm not sure why it confused you. ... Windows version of fgets(), confuse DotNet even worse, and confuse you. ... Bare LF characters in Unix would be a non-issue and that's why my ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Different PocketPC versions
    ... A alternative I find myself using when I need to not confuse them ... with PPCs is: custom CE-based devices ... > devices that use a version of the Windows CE operating system". ... >>is different from the CE market anyway, so ...
    (microsoft.public.pocketpc.developer)
  • Re: interface
    ... what do you think of C++ as language for speak with electronics device? ... Writing portable code has nothing to do with the operating system or ... independent of which operating system you are using. ... If it is meant to run on Windows only, ...
    (comp.programming)
  • Re: Blocking read() policy?
    ... >> then it will perform bad on any platform including Windows. ... well designed applications on the other, provided you invest time in the ... Writing portable code from the beginning pays off big time. ... memory primitives, network I/O, file and directory code, low-level timing ...
    (comp.os.linux.development.system)