Re: Another PL/I cant

From: James Giles (jamesgiles_at_worldnet.att.net)
Date: 08/30/04

  • Next message: Bill Bertram: "Re: How many years we have been programming in Fortran"
    Date: Sun, 29 Aug 2004 23:24:31 GMT
    
    

    David Frank wrote:
    ...
    > I'm not going to beat the dead horse issue of why F2003 doesnt have dynamic
    > formats
    > despite desire expressed by comp.lang.fortran readers to adopting <..>
    > syntax

    When have more that a tiny minority done that?

    > re: CVF not accepting your format
    > It accepts my inline formatting below which ought to portable.
    >
    > read (hex,'('//slen2s(string)//'z2)') (string(i:i),i=1,len(string))
    >
    > ! ------------------------------------
    > function slen2s(s) result (out)
    > character(*),intent(in) :: s
    > character(4) :: out
    > write (out,'(i4.4)') len(s)
    > end function
    > end program

    That doesn't do the same thing. I want an overload of the
    concatenate operator that accepts INTEGER operands,
    not a function that converts a string to its length expressed
    as a string. Nor do I want to *always* produce 4 characters
    in the answer. I want the length of the result string to be
    the actual minimal number of characters required to hold
    the converted integer.

    That is:
       i = 123
       String = "A" // i // "B"

    should result in a value of String equal to "A123B". And:

       i=-5
      String = "A" // i // "B"

    should result in a value of String equal to "A-5B".

    Now, as it happens I've just now (this minute) finished getting
    a version of this to work on CVF. The differences between
    the working version and the non-working versions are trivial
    (rearrangements of integer expressions, or putting redundant
    parenthesis around operands). And even so I'm still getting
    warning errors to the effect that the standard requires a certain
    function result to be of type integer - and it *is*, so why warn?

    As I said last week on the other thread addressing this problem,
    CVF apparently has real issues with this stuff.

    In any case, with the overload of the contatenate operator (which
    finally works even on CVF), the following is preferable (lots)
    to the "dynamic format" idea:

       read (hex,'('//len(string)//'z2)')...

    Note that this doesn't involve the use of any new functions
    other than the understanding of the extended capability of
    the // operator. So, users needn't have to browse all over
    to find out what some arcane slen2s function does. (I think
    this use of the concatenate operator is useful enough to be
    made an intrinsic property of the operator.)

    -- 
    J. Giles
    "I conclude that there are two ways of constructing a software
    design: One way is to make it so simple that there are obviously
    no deficiencies and the other way is to make it so complicated
    that there are no obvious deficiencies."   --  C. A. R. Hoare
    

  • Next message: Bill Bertram: "Re: How many years we have been programming in Fortran"

    Relevant Pages