Parameter Denotations 7(Pdf)

Parameter Denotations 7(Pdf)

↓ cut ↓ ↓ cut ↓ ¡ ¢ ¢ ¢ ¢ ¢ ¡ ¢ ¢ ¢ ¢ ¢ 2/26/106 defparm FOIL 1 | | + + Parameter Denotations £ What does a parameter mean? Ð An ``actual parameter'' given env sto, yields an Argument Ð Meaning of a formal parameter depends on the ``parameter passing'' mechanism £ Kinds of Parameter Mechanisms (partial taxonomy) Ð Definitional: FP bound to actual at call time (no allocation) ¤ Constant parameters ¤ Variable parameters ¤ Procedural parameters ¤ Functional parameters Ð Copy Mechanisms: FP is an allocated local variable initialized at call time ¤ Value (copy-in) parameters ¤ Result (copy-out) parameters ¤ Copy-in/Copy-out parameters + + | | ¡ ¢ ¢ ¢ ¢ ¢ ¡ ¢ ¢ ¢ ¢ ¢ 2/26/106 defparm FOIL 2 | | + + IMP 2d = IMP 1 + Definitional Parameters £ Features Ð argument can be first-class value or reference (Location , l-value). Ð latter are often called var parameters (implemented by copying referencesÐthis is call- by-reference) Ð const parameters are not call-by-value: nothing is copied, no local variable exists. Equivalent to a const declaration at start of subroutine body. Ð expressions still only evaluate to first-class values (no l-valued expressions in this language) £ Syntax of IMP 2d Formal-Parameter::= const Identifier : Type-denoter | var Identifier : Type-denoter Actual-Parameter::=Expression | var Identifier + + | | ¡ ¢ ¢ ¢ ¢ ¢ ¡ ¢ ¢ ¢ ¢ ¢ 2/26/106 defparm FOIL 3 | | + + IMP 2d Semantics £ Specify semantic domains Value = . Argument = value Value + variable Location Function = . Procedure = . Bindable = value Value + variable Location + function Function + procedure Procedure Ð superset of Argument £ Specify Contextual Constraints Ð proc p(var x : . ) declaration ⇒ p(var I) call Ð proc p(const c : . ) declaration ⇒ p(E) call £ Specify semantic functions Ð as for IMP 1 with edits as follows + + | | ¡ ¢ ¢ ¢ ¢ ¢ ¡ ¢ ¢ ¢ ¢ ¢ 2/26/106 defparm FOIL 4 | | + + Semantic Function for Actual-Parameter £ Actual-Parameter like an Expression , but can yield Value (r-value) or Location (l-value) Argument = value Value + variable Location give − argument : Actual-Parameter → (Environ → Store → Argument ) give − argument[[var I]] env sto = let variable loc = find(env, I) in variable loc give − argument[[E]] env sto = value(evaluate[[E]] env sto ) Ð tag Value as Argument Expression Semantics evaluate[[I(AP) ]] env sto = let function func = find(env, I) in let arg = give − argument[[AP]] env sto in func arg sto Command Semantics execute[[I(AP) ]] env sto = let procedure proc = find(env, I) in let arg = give − argument[[AP]] env sto in proc arg sto + + | | ¡ ¢ ¢ ¢ ¢ ¢ ¡ ¢ ¢ ¢ ¢ ¢ 2/26/106 defparm FOIL 5 | | + + Semantic Function for Formal-Parameter £ What does a definitional FP mean? £ Formal Parameters denote (Argument → Environ ) maps Ð they take an argument and return a name binding Ð semantic rule for func /proc declaration overlays this elementary binding on the environment of definition (see below) bind − parameter : Formal-Parameter → (Argument → Environ ) bind − parameter[[var I : T]] (variable loc) = bind(I, variable loc) bind − parameter[[const I : T]] (value val) = bind(I, value val) + + | | ¡ ¢ ¢ ¢ ¢ ¢ ¡ ¢ ¢ ¢ ¢ ¢ 2/26/106 defparm FOIL 6 | | + + Declaration Semantics £ function declaration: generalizes prior approach as follows: EXP 1: let func = λx . λσ.evaluate[[E]] overlay([FP →| x], env) σ EXP 2d: let func = λx . λσ . evaluate[[E]] overlay(bind − parameter[[FP]] x, env) σ elaborate[[func I(FP) ∼ E]] env sto = let func = λx . λσ . evaluate[[E]] overlay(bind − parameter[[FP]] x, env) σ in ( bind(I, function func) , sto ) £ procedure declaration analogous elaborate[[proc I(FP) ∼ C]] env sto = let proc = λx . λσ . execute[[C]] overlay(bind − parameter[[FP]] x, env) σ in ( bind(I, procedure proc) , sto ) + + | | ↑ cut ↑ ↑ cut ↑.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us