mud8_and_9

mud8_and_9 - Lecture C8 and C9: Types / Packages Response...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture C8 and C9: Types / Packages Response to 'Muddiest Part of the Lecture Cards' (41 respondents, out of 70students) 1) The difference between functions and procedures? (7 students) Both functions and procedures are classified as subprograms in Ada. The overall format of both is the same. The difference however is in the details of the header and the number of values returned. Functions have the format: <function header> <local variables and constants> begin <function body> end <function name>; The function header has the following format: function <function name> ( <formal parameter name> : <data type>; <formal parameter name> : <data type>; . . . ) return <data type> is Functions must always return a value of the type specified in the function header. In addition, all the parameters of the function header are of type in . Procedures on the other hand can have zero or more outputs. The parameters in the procedure header can be of type in , out or in out . Procedures have the format: <procedure header> <local variables and constants> begin <procedure body> end <procedure name>; The procedure header has the following format: procedure <procedure name> ( <formal parameter name> : <mode> <data type>; <formal parameter name> : <mode> <data type>; . . . ) is Mode specifiers are: ± in : the variable is of type input and cannot be changed inside the subprogram. In other words, it can only appear in an expression or the right hand side of an assignment statement ± out : the variable is an output variable and can only appear in the left hand side of an assignment statement. ± in out : the variable can appear on either side of an assignment statement or in an expression.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2) I do not understand Formal and Actual paramters. Please explain a transfer of control? (and similar questions) (9 students) The fundamental idea behind using parameters in function or procedure calls is to exchange information. Ada uses a mechanism called pass by value , to exchange information between subprograms. Consider the procedure call below:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

mud8_and_9 - Lecture C8 and C9: Types / Packages Response...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online