Robin wrote:

> > One good example is where IBM doesn't match the standard, it doesn't
> > always
> > evaluate the operand of the LENGTH builtin (which could invoke a  
> > function) if it can
> > compute the result at compile-time.   So, even though the expression 
> > might have a
> > side-effect, it is not invoked.
>  
> If the string is fixed length, PL/I doesn't need to evaluate anything.
> If the argument to LENGTH is an expression, the expression might need to
> be evaluated.
> For example, LENGTH (A || B) would not require the evaluation of the
> expression
> when both A and B are of fixed length.  The length would be available at
> compile time.
>

Consider this example:

   ex: proc options(main);

    dcl var fixed bin(31) init(0);

    dcl l fixed bin(31);


     sub: proc(val) returns( char(8) );
         dcl val fixed bin(31);
         var = val;
         return ('Hi there');
     end;

    l = length(sub(10));

    put skip list('l is ', l);
    put skip list('var is', var);

  end;

 what do you expect the output of that to be?   In my reading of the PL/I 
standard,
 the output should be:
 
   l is                                 8 
   var is                               10

 as it clearly indicates that argument to builtin functions should be evaluated.

 You're right in that if the determination can be made at compile-time, there 
 is no problem with the compiler simply producing a constant with the 
appropriate
 attributes.

   - Dave Rivers -

p.s.I have taken the liberty of changing the subject...


 

     



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to