Re: To "TAB" or not to "TAB"

From: Richard Maine (nospam_at_see.signature)
Date: 03/30/04


Date: 30 Mar 2004 13:53:36 -0800


"Gary L. Scott" <garyscott@ev1.net> writes:

> I can put EOL characters, CR, LF, in fact any 8-bit value positive or
> negative I want etc. in character strings now in every compiler I'm
> aware of, on any operating system I'm aware of.

You can? Well I can't. If there is any way to do it with, for
example, the Nag compiler, then I sure don't know what it is. If
I write, for example

   program hi
     write(*,*) "Hello
world."
   end

that newline between the Hello and the world is just not going
to work out well. As in

Error: hi.f90, line 2: Unterminated character literal
       detected at )@'Hello
Error: hi.f90, line 2: syntax error
       detected at )@'Hello
***Malformed statement
Error: hi.f90, line 3: Unrecognised statement
***Malformed statement
Error: hi.f90, line 3: Unexpected '.' found
       detected at <illegal token>@.
Error: hi.f90, line 3: Unterminated character literal
       detected at .@'

If I put an LF character in the file, it is going to get interpreted
as a end of a source code line, which won't have the expected effect
at all. If there is some convention to enter it in a nonobvious
way, I sure don't see it documented. It would require that the
compiler explicitly provide something to make that work.

> The standard doesn't
> need to define what the operating system (or source editor) does with
> any particular value to state that the compiler/processor itself
> performs no special action on the value within a string, regardless of
> how the value is inserted by the programmer.

But again, what you are describing is *ALREADY* what the standard
says. If there is a graphic character in the string, then the
standard specifies how it is interpreted - and no "special action"
is allowed. If the compiler can't handle a character in a string
(like the compilers I use can't handle LF), then the standard says
it is illegal to put that character in a string.

If you aren't asking for the status quo, and you aren't insisting
that compilers be required to handle every 8-bit pattern, then I
still don't understand what you are asking for. It sounds like you
are insisting that the compiler be required to handle every
8-bit pattern (ok, every "representable character" in
standard-speak).

Of course, if you require that every "representable character"
work, that won't change much anyway in reality. That will just
mean that the problematic characters are declared nonrepresentable
by the processor unless you do break down and insist that every
8-bit pattern be representable (which assumes a lot).

In order to handle every 8-bit pattern, the compiler *WILL* have do do
special processing, presumably by defining some kind of escape
mechanism (at least on a UNix/Windows/Mac box, which is a pretty
signicant fraction of the market - I'm aware that VaXen and IBM
mainframes, and a few other rare systems can do it). It seem to me
that you are saying that the compiler should do no special processing,
but then you are also insisting that it have capabilities that can't
be done without special processing.

If you want to require that such special processing be done, I could
understand that, but I don't see how you can ask for things that
require special processing and also insist that there be none,
unless you know some magic that I don't know. How *CAN* one represent
an LF in a literal string on Unix without some special processing?
Or do you consider interpreting \n (of whatever) as a newline
not to be special processing?

This is all to trivial and obvious to be a real disagreement.
Clearly, one or both of us is just not inderstanding the other.

-- 
Richard Maine                       |  Good judgment comes from experience;
email: my first.last at org.domain  |  experience comes from bad judgment.
org: nasa, domain: gov              |        -- Mark Twain


Relevant Pages

  • Re: PL/I string representations
    ... >> of the language, so it was interesting to me, hopefully it will be to ... I found a workable compiler for Fortran in 1971 (with a bug ... >> The specified length is the minimum, and each time a character ... >> string is assigned to E, the length is stored with it. ...
    (comp.programming)
  • Re: when substring equals string
    ... CHARACTER:: String ... The unit number is attached to a file via an OPEN statement. ... question is about a character variable, ... Like in the way the operator invoked the compiler. ...
    (comp.lang.fortran)
  • Re: Newbie: Is it possible for a function to return a String or Character Arrays?
    ... The hard part about this is not returning a string, ... If you wanted a fixed-length string returned, you could declare the ... If your f95 compiler implements the allocatable stuff TR (or if you ... I don't think that the allocatable TR included allocatable character ...
    (comp.lang.fortran)
  • Re: Unexpected regex Behavior
    ... wish to do special processing if any chunk ends with the carriage-return ... the "^" character is guaranteed to match only the beginning ... the "$" character only the end (or before the newline at ... the string contains only one line. ...
    (comp.lang.perl.misc)
  • Re: Unexpected regex Behavior
    ... wish to do special processing if any chunk ends with the carriage-return ... the "^" character is guaranteed to match only the beginning ... the "$" character only the end (or before the newline at ... the string contains only one line. ...
    (comp.lang.perl.misc)