maddy
maddy

Reputation: 827

Doubts in ada language involving procedures

I am a beginner in Ada and I have come across a piece of code which is shown below:

                   procedure Null_Proc is
                   begin
                    null;
                   end;

Now as per my knowledge the procedure in Ada doesn't return anything. My doubt is what does this procedure Null_proc do? I mean I am not clear with the definition of the procedure.

Upvotes: 1

Views: 314

Answers (2)

T.E.D.
T.E.D.

Reputation: 44804

I've been known to write main routines that way when all the "real code" was in the withed packages. This is particularly likely if your program uses tasking, as the main routine cannot accept rendezvous like a task can, so it often ends up with nothing useful to do. Your entire program will stay active until all tasks complete, so the main routine really doesn't have to do anything.

Another possible use would be for implementing some kind of default routine to supply to callbacks.

Upvotes: 3

Jonathan Leffler
Jonathan Leffler

Reputation: 753605

It does nothing.

It might be useful when a procedure must be called but nothing must be done; otherwise, it has little value. (I am working from memory; I assume that Ada does allow functions or procedures as parameters to other functions - in terms of C, pointers to functions.)

Upvotes: 4

Related Questions