comp.lang.ada
 help / color / mirror / Atom feed
* Keyword "null" Question
@ 2003-01-17 15:04 Michael Bustillo
  2003-01-17 15:10 ` Lutz Donnerhacke
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Michael Bustillo @ 2003-01-17 15:04 UTC (permalink / raw)


While reviewing the Ada LRM, it makes note that the Ada keyword "null"
does nothing except pass to the next statement.  This seems intuitive
enough, however...

I'm currently attempting to reverse engineer some code so that it can be
converted to another language, and I've run across the following:

    if SOME_EVENT_TOOK_PLACE then
        null;
    end if;

This statement is simply standing alone by itself, not part of any
"case-like" structure or anything sneaky.  I guess my question is when
it says "...it does nothing..." does it actually mean that it is putting
a NO OP there?  Because then this would actually be doing something,
most likely a timing issue, and that's what I need to know.

I appreciate your time, and thanks.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keyword "null" Question
  2003-01-17 15:04 Keyword "null" Question Michael Bustillo
@ 2003-01-17 15:10 ` Lutz Donnerhacke
  2003-01-17 23:16   ` Jeffrey Carter
  2003-01-17 15:46 ` Mark Johnson
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Lutz Donnerhacke @ 2003-01-17 15:10 UTC (permalink / raw)


* Michael Bustillo wrote:
>     if SOME_EVENT_TOOK_PLACE then
>         null;
>     end if;
>
> This statement is simply standing alone by itself, not part of any
> "case-like" structure or anything sneaky.  I guess my question is when
> it says "...it does nothing..." does it actually mean that it is putting
> a NO OP there?

For the null statement: Yep.

> Because then this would actually be doing something,
> most likely a timing issue, and that's what I need to know.

No. If SOME_EVENT_TOOK_PLACE is pure, the whole IF statement is a NO OP.
Otherwise it's the same as
  declare
     dummy : constant Boolean := SOME_EVENT_TOOK_PLACE;
  begin
     null;
  end;



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keyword "null" Question
  2003-01-17 15:04 Keyword "null" Question Michael Bustillo
  2003-01-17 15:10 ` Lutz Donnerhacke
@ 2003-01-17 15:46 ` Mark Johnson
  2003-01-17 16:35 ` Peter Amey
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Mark Johnson @ 2003-01-17 15:46 UTC (permalink / raw)


Michael Bustillo wrote:
> 
> While reviewing the Ada LRM, it makes note that the Ada keyword "null"
> does nothing except pass to the next statement.  This seems intuitive
> enough, however...
> 
> I'm currently attempting to reverse engineer some code so that it can be
> converted to another language, and I've run across the following:
> 
>     if SOME_EVENT_TOOK_PLACE then
>         null;
>     end if;
> 
> This statement is simply standing alone by itself, not part of any
> "case-like" structure or anything sneaky.  I guess my question is when
> it says "...it does nothing..." does it actually mean that it is putting
> a NO OP there?  Because then this would actually be doing something,
> most likely a timing issue, and that's what I need to know.

Hmm. Actually in 5.1(13) I read...
  The execution of a null_statement has no effect.
so the NO OP is not required (and I could argue should not even appear).
Without knowing what "SOME_EVENT_TOOK_PLACE" does, it appears to me that
this code is calling the function and discarding the return value (to
avoid the generation of a local variable).

If it is a timing issue - it appears to be a quite subtle one (and
fraught with error in the case of translation). However, now that I
think about it some more, the code may have been present to provide a
"hook" for a breakpoint. You could break on the null statement to then
walk through the condition you are trying to debug.
  --Mark



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keyword "null" Question
  2003-01-17 15:04 Keyword "null" Question Michael Bustillo
  2003-01-17 15:10 ` Lutz Donnerhacke
  2003-01-17 15:46 ` Mark Johnson
@ 2003-01-17 16:35 ` Peter Amey
  2003-01-17 17:31   ` Pascal Obry
  2003-01-17 18:16   ` Warren W. Gay VE3WWG
  2003-01-18  2:54 ` Steve
  2003-01-18 14:46 ` Marin David Condic
  4 siblings, 2 replies; 10+ messages in thread
From: Peter Amey @ 2003-01-17 16:35 UTC (permalink / raw)




Michael Bustillo wrote:
> 
> While reviewing the Ada LRM, it makes note that the Ada keyword "null"
> does nothing except pass to the next statement.  This seems intuitive
> enough, however...
> 
> I'm currently attempting to reverse engineer some code so that it can be
> converted to another language, and I've run across the following:
> 
>     if SOME_EVENT_TOOK_PLACE then
>         null;
>     end if;
> 
> This statement is simply standing alone by itself, not part of any
> "case-like" structure or anything sneaky.  I guess my question is when
> it says "...it does nothing..." does it actually mean that it is putting
> a NO OP there?  Because then this would actually be doing something,
> most likely a timing issue, and that's what I need to know.
> 
> I appreciate your time, and thanks.

I would have thought that this is most likely a hook for some planned
future development.  I have written code that cased or looped over an
enumeration type with a single element for example where extension
seemed likely.  I am confident that the source statements would not
generate any object code  given any half-decent optimization.

Peter



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keyword "null" Question
  2003-01-17 16:35 ` Peter Amey
@ 2003-01-17 17:31   ` Pascal Obry
  2003-01-17 17:40     ` Larry Kilgallen
  2003-01-17 18:16   ` Warren W. Gay VE3WWG
  1 sibling, 1 reply; 10+ messages in thread
From: Pascal Obry @ 2003-01-17 17:31 UTC (permalink / raw)



Peter Amey <peter.amey@praxis-cs.co.uk> writes:

> Michael Bustillo wrote:
> > 
> > I'm currently attempting to reverse engineer some code so that it can be
> > converted to another language, and I've run across the following:
> > 
> >     if SOME_EVENT_TOOK_PLACE then
> >         null;
> >     end if;
> > 
> 
> I would have thought that this is most likely a hook for some planned
> future development.  

In that case there is something very important missing... some comments ;)

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keyword "null" Question
  2003-01-17 17:31   ` Pascal Obry
@ 2003-01-17 17:40     ` Larry Kilgallen
  0 siblings, 0 replies; 10+ messages in thread
From: Larry Kilgallen @ 2003-01-17 17:40 UTC (permalink / raw)


In article <uu1g78yz4.fsf@wanadoo.fr>, Pascal Obry <p.obry@wanadoo.fr> writes:
> 
> Peter Amey <peter.amey@praxis-cs.co.uk> writes:
> 
>> Michael Bustillo wrote:
>> > 
>> > I'm currently attempting to reverse engineer some code so that it can be
>> > converted to another language, and I've run across the following:
>> > 
>> >     if SOME_EVENT_TOOK_PLACE then
>> >         null;
>> >     end if;
>> > 
>> 
>> I would have thought that this is most likely a hook for some planned
>> future development.  
> 
> In that case there is something very important missing... some comments ;)

The entire program was not posted (thank goodness).

Perhaps that segment was up to the comment standards for the rest of
the program :-(



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keyword "null" Question
  2003-01-17 16:35 ` Peter Amey
  2003-01-17 17:31   ` Pascal Obry
@ 2003-01-17 18:16   ` Warren W. Gay VE3WWG
  1 sibling, 0 replies; 10+ messages in thread
From: Warren W. Gay VE3WWG @ 2003-01-17 18:16 UTC (permalink / raw)


Peter Amey wrote:
> Michael Bustillo wrote:
> 
>>While reviewing the Ada LRM, it makes note that the Ada keyword "null"
>>does nothing except pass to the next statement.  This seems intuitive
>>enough, however...
>>
>>I'm currently attempting to reverse engineer some code so that it can be
>>converted to another language, and I've run across the following:
>>
>>    if SOME_EVENT_TOOK_PLACE then
>>        null;
>>    end if;
>>
>>This statement is simply standing alone by itself, not part of any
>>"case-like" structure or anything sneaky.  I guess my question is when
>>it says "...it does nothing..." does it actually mean that it is putting
>>a NO OP there?  Because then this would actually be doing something,
>>most likely a timing issue, and that's what I need to know.
>>
>>I appreciate your time, and thanks.
> 
> 
> I would have thought that this is most likely a hook for some planned
> future development.  I have written code that cased or looped over an
> enumeration type with a single element for example where extension
> seemed likely.  I am confident that the source statements would not
> generate any object code  given any half-decent optimization.
> 
> Peter

One other possibility might be that it was pre-processed by some
tool that precompiled out some optional code (something like gnatprep).
Or more likely, the code that used to be there was commented out and
a null was stuck in there to make it compile ;-)

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keyword "null" Question
  2003-01-17 15:10 ` Lutz Donnerhacke
@ 2003-01-17 23:16   ` Jeffrey Carter
  0 siblings, 0 replies; 10+ messages in thread
From: Jeffrey Carter @ 2003-01-17 23:16 UTC (permalink / raw)


Lutz Donnerhacke wrote:
> * Michael Bustillo wrote:
> 
>>    if SOME_EVENT_TOOK_PLACE then
>>        null;
>>    end if;
>>
>>This statement is simply standing alone by itself, not part of any
>>"case-like" structure or anything sneaky.  I guess my question is when
>>it says "...it does nothing..." does it actually mean that it is putting
>>a NO OP there?
> 
> 
> For the null statement: Yep.

This is incorrect. A null statement does not require generating any 
object code. No decent Ada compiler outputs a NO OP code for null 
statements.

Without knowing what SOME_EVENT_TOOK_PLACE is it's impossible to 
conjecture on why this is there.

-- 
Jeff Carter
"Sheriff murdered, crops burned, stores looted,
people stampeded, and cattle raped."
Blazing Saddles




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keyword "null" Question
  2003-01-17 15:04 Keyword "null" Question Michael Bustillo
                   ` (2 preceding siblings ...)
  2003-01-17 16:35 ` Peter Amey
@ 2003-01-18  2:54 ` Steve
  2003-01-18 14:46 ` Marin David Condic
  4 siblings, 0 replies; 10+ messages in thread
From: Steve @ 2003-01-18  2:54 UTC (permalink / raw)


Is "SOME_EVENT_TOOK_PLACE" a function?  If so this is one way of discarding
the result.

If "SOME_EVENT_TOOK_PLACE" is a variable this may have been a trick to keep
the compiler from complaining about an unused variable or an optimizer
removing the variable altogether.

If you have the original development environment available you might just
try compiling with the code commented out.  The result may give you your
answer.

Steve
(The Duck)

"Michael Bustillo" <Michael_B_Bustillo@noSpam.raytheon.com> wrote in message
news:3E281B97.76F47E30@noSpam.raytheon.com...
> While reviewing the Ada LRM, it makes note that the Ada keyword "null"
> does nothing except pass to the next statement.  This seems intuitive
> enough, however...
>
> I'm currently attempting to reverse engineer some code so that it can be
> converted to another language, and I've run across the following:
>
>     if SOME_EVENT_TOOK_PLACE then
>         null;
>     end if;
>
> This statement is simply standing alone by itself, not part of any
> "case-like" structure or anything sneaky.  I guess my question is when
> it says "...it does nothing..." does it actually mean that it is putting
> a NO OP there?  Because then this would actually be doing something,
> most likely a timing issue, and that's what I need to know.
>
> I appreciate your time, and thanks.
>





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keyword "null" Question
  2003-01-17 15:04 Keyword "null" Question Michael Bustillo
                   ` (3 preceding siblings ...)
  2003-01-18  2:54 ` Steve
@ 2003-01-18 14:46 ` Marin David Condic
  4 siblings, 0 replies; 10+ messages in thread
From: Marin David Condic @ 2003-01-18 14:46 UTC (permalink / raw)


That's going to depend on the optimizer for your particular compiler. The
language only specifies that in some "virtual machine" sense, nothing
happens that impacts your program - timing issues not being considered. I
believe that it is possible for the optimizer to look at the whole "if"
statement and throw it away - but I could be wrong about this. (I have not
had to review that aspect of the standard for some time.) That could have
implications if the logical expression in the "if" had side effects.
(Someone with better knowledge than I have might want to correct this...)

You need to check the output of your compiler with various optimization
levels set. Note that it is legal for a compiler to do something illegal
while optimizing just so long as there is some mode in which the compiler
does what the ARM requires. (IOW, if optimizing away the if chech were
illegal, it still might be made to do so in some optimization mode, so long
as in some "Standard Ada" mode it does not.)

MDC
--
======================================================================
Marin David Condic
I work for: http://www.belcan.com/
My project is: http://www.jast.mil/

Send Replies To: m c o n d i c @ a c m . o r g

    "I'd trade it all for just a little more"
        --  Charles Montgomery Burns, [4F10]
======================================================================

Michael Bustillo <Michael_B_Bustillo@noSpam.raytheon.com> wrote in message
news:3E281B97.76F47E30@noSpam.raytheon.com...
> While reviewing the Ada LRM, it makes note that the Ada keyword "null"
> does nothing except pass to the next statement.  This seems intuitive
> enough, however...
>
> I'm currently attempting to reverse engineer some code so that it can be
> converted to another language, and I've run across the following:
>
>     if SOME_EVENT_TOOK_PLACE then
>         null;
>     end if;
>
> This statement is simply standing alone by itself, not part of any
> "case-like" structure or anything sneaky.  I guess my question is when
> it says "...it does nothing..." does it actually mean that it is putting
> a NO OP there?  Because then this would actually be doing something,
> most likely a timing issue, and that's what I need to know.
>
> I appreciate your time, and thanks.
>





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-01-18 14:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-17 15:04 Keyword "null" Question Michael Bustillo
2003-01-17 15:10 ` Lutz Donnerhacke
2003-01-17 23:16   ` Jeffrey Carter
2003-01-17 15:46 ` Mark Johnson
2003-01-17 16:35 ` Peter Amey
2003-01-17 17:31   ` Pascal Obry
2003-01-17 17:40     ` Larry Kilgallen
2003-01-17 18:16   ` Warren W. Gay VE3WWG
2003-01-18  2:54 ` Steve
2003-01-18 14:46 ` Marin David Condic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox