[comp.sys.hp] Disturbing Pascal Behavior

rick@bnrunix.UUCP (Richard Johns X7191) (07/21/89)

I really hope that someone can tell me it ain't so:  under HP/UX6.2, using the
"Pascal [Rev 10.1.1.3   88/04/22]" compiler I try to compile:

$STANDARD_LEVEL 'HP_MODCAL'$
$ALLOW_PACKED ON$
MODULE test;

EXPORT

function poops(s : string[80]) : string[80];
	.
	.
	.

and get:

     7:     7:D        1 function poops(s : string[80]) : string[80];
                                                 ^^            ^^
>>>>>> Error at f.p/7
>>>>>> Type identifier required;
>>>>>> Error in parameter list;
>>>>>> Type identifier required;
>>>>>> Expected a semicolon ";";
>>>>>> Symbol is not valid in this context;


What's the story?  I can declare variables of type string, but can't put them
into a function declaration with or without the "[80]", using  VAR, or using
$ALLOW_PACKED$.  I have seen anything in the manual that says it shouldn't be 
possible.

Thanks in advance.
 
Rick


 

louxj@jacobs.CS.ORST.EDU (John W. Loux) (07/23/89)

In article <231@bnrunix.UUCP> rick@bnrunix.UUCP (Richard Johns X7191) writes:
>
>function poops(s : string[80]) : string[80];
>
>and get:
>
>     7:     7:D        1 function poops(s : string[80]) : string[80];
>                                                 ^^            ^^
>>>>>>> Error at f.p/7
>
>What's the story?  I can declare variables of type string, but can't put them
>into a function declaration with or without the "[80]", using  VAR, or using
>$ALLOW_PACKED$.  I have seen anything in the manual that says it shouldn't be 
>possible.

My manual says that the result type must be "any previously defined type".
Though this does not completely or sufficiently address your case (and a
cursory examination of the manual fails to shed any more light), I have either
read somewhere or gleaned from experience that both the return type of
functions and the parameter types of both functions and procedures MUST be
predefined types.  STRING[80] is a type declaration, not a predefined type.

For this reason, scalar declarations (i.e., 0..9) and record declarations are
also forbidden.  $ALLOW_PACKED$ has nothing to do with it.  (This has been my
experience with HP Pascal since it was introduced on the first series 200
machines.)

Thus, define

    TYPE strng = STRING[80];

and your function as

    FUNCTION poops(s : strng) : strng;

and all should be well.

John W. Loux
louxj@jacobs.cs.orst.edu