John Gilmore wrote:

Implementation dependencies are in general undesirable, but
inter-language linkages of the kind being talked about here are always
and ineluctably doubly implementation-dependent.

Consider now the PL/I statements

declare pbs32_sysnull_image
 static aligned bit(32) initial('00000000'b4) ;
declare p pointer,
 pbs32 aligned bit(32) based(addr(p)),
 addr builtin ;

pbs32 = pbs32_sysnull_image ;

This kind of brutal data-type punning, common in assembly language, is
anathema to little old ladies of both sexes in statement-level
languages.  It nevertheless has its uses; it is direct and efficient,
and, whether written in C or PL/I, it will not be optimized away.

John Gilmore, Ashland, MA 01721 - USA

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

Actually - if I'm reading your PL/I correctly, it's quite possible
to be surprisingly optimized (and likely not what you wanted it to do)
in ANSI C.

I think the equivalent C code would be:

    int pbs32_sysnull_image = 0;
    void *p;
    int * pbs32 = &p;

   *pbs32 = pbs32_sysnull_image;

If the intent is to set 'p' to all zeros, then this will not necessarily
be the case in ANSI C.

The C compiler is allowed to optimize based on types; so the assignment
of the 'int' type in the assignment statement is not obliged to be seen
as a write to the datum 'p'.

Then, if you had something like this:

      p = &somewhere;

      *pbs32 = pbs32_sysnull_image;

     if(p == &somewhere) {
        printf("fail...\n");
     }


A valid ANSI C implementation, with a reasonable optimizer,
can correctly translate this program so that you see

       fail...

printed out.   What you have done here is techinically illegal,
and the compiler is free to do what it wants.

Having said that,   many compilers only do this if you have
an option to allow it.. because many programmers find it
surprising.

I'm not sure what PL/I would have to say about it.

     - Dave Rivers -

--
[email protected]                        Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

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

Reply via email to