Re: backslash-issues



On 2005-06-29, Bart Vandewoestyne <MyFirstName.MyLastName@xxxxxxxxxx> wrote:
>
> [...]
> Now this is something that I've found strange... F being a language that
> tries to force the programmer 'good' programming style, wouldn't it then
> have made more sense to keep the ACHAR intrinsic instead of the CHAR
> intrinsic? For as far as i understand, both intrinsics do the same but
> CHAR is less portable then ACHAR because it does not depend by definiton
> on the ASCII character table?
>
> Walt, any comments?

Hmm... As i did not have my 'The F programming language' book at hand
yesterday when I posted this, i had to look things up on the Net. But
today I've found this in my book, page 136, section 8.5.1:

char(i) is of type character and length one. It returns the character
in position i in the ASCII collating sequence. The value of i must be
in the range 0 \leq i \leq 127.

So actually, where you can't be sure that you are using the ASCII
collating sequence if you interpret CHAR according to the Fortran95
standard, you *can* be sure you are using the ASCII collating sequence
if you're using F. So that would make this solution portable in F:

character(len=*), parameter :: backslash = char(92)

But unfortunately, if i compile this as being Fortran95, i still cannot
be sure I will get the right character, because the interpretation of
the 92 will depend on the processor's character set :-(

Still, when trying to write both F and Fortran95 compatible code, i
think the above suggestion is the best i can come up with. And all i
can do is hope that my Fortran95 processor will also use the ASCII
collating sequence.

Or does anybody else see another solution?

Regards,
Bart

--
"Share what you know. Learn what you don't."
.



Relevant Pages