[Info-vax] String handling

Paul Sture nospam at sture.ch
Sun Feb 16 16:17:46 EST 2014


On 2014-02-16, Simon Clubley <clubley at remove_me.eisner.decus.org-Earth.UFP> wrote:
> On 2014-02-15, Paul Sture <nospam at sture.ch> wrote:
>> On 2014-02-15, Simon Clubley <clubley at remove_me.eisner.decus.org-Earth.UFP> wrote:
>>>
>>> Thanks, Hoff; I've never used DEC/CPQ/HP BASIC.
>>>
>>> That fits with my definition of a fixed length string and the closest in
>>> Ada would be a variable of the String data type, which, once created, has
>>> a immutable length.
>>>
>>> However, unless you call the appropriate function, you need to handle
>>> the padding/truncation yourself. This is in keeping with Ada's safety
>>> orientated mindset.
>>
>> Every language that I did in early days (RPG, DIBOL, COBOL etc) had clearly
>> defined behaviour here.   The documentation and any training materials
>> would contain examples which covered both space filling and truncation such
>> as can be seen here for HP COBOL:
>>
>><http://h71000.www7.hp.com/doc/82final/6297/6297pro_025.html#alpha_just_move_sec>
>>
>> The 's' in those table entries stands for 'space'
>>
>
> Thanks Paul.
>
> The safety aspect here is not undefined behaviour within the language
> but with language constructs which can lose or alter data without that
> potential loss/alteration of data being marked clearly within the
> application source code.

That reminds me of the statement you see on the previous page to the above
URL:

<http://h71000.www7.hp.com/doc/82final/6297/6297pro_024.html#bottom_024>

"The MOVE statement alters the contents of every character position in the
receiving item."

But in the special case of strings you can specify the target
as a substring foo(offset:Length)

cf Fortran 77 substrings which IIRC are addressed as
foo(start_offset,end_offset)

> That's why Ada has very few implicit type conversions allowed compared
> to some other languages. You can still do the type conversion in many
> cases; it's just that you have to do it in a way which draws attention
> to it within the source code.

I think I recall that from Pascal as well as Ada.  Frustrating at first
but it is quite clear what you are doing (e.g. moving a word into a byte).

COBOL's approach is to issue warnings in the compiler listing, but the
volume of them could get overwhelming.  In other languages you could try
to achieve a warning free compilation but in the COBOL environment we were
using (think using files from or for non-COBOL environments) this was nigh
impossible.

--
Paul Sture



More information about the Info-vax mailing list