{VERSION 2 3 "SUN SPARC SOLARIS" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "Hyperlink" -1 17 "" 0 1 0 128 128 1 0 0 1 0 0 0 0 0 0 } {CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "2 D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 }{CSTYLE "" 0 21 "" 0 1 0 0 0 1 0 0 0 0 2 0 0 0 0 }{CSTYLE "Help Heading" -1 26 "" 1 14 0 0 0 0 0 1 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }1 0 0 0 6 6 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Bullet Item" 0 15 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 3 3 0 0 0 0 0 0 15 2 }} {SECT 0 {PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 7 "Advice:" }{TEXT -1 41 " One level evaluation for local variables " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 249 "Insi de a procedure, Maple uses one-level evaluation on local variables, in stead of the full evaluation which is used on global variables. In mo st cases this is all that is needed, and in some cases it results in s ubstantially improved efficiency. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 71 "qproc:= proc(x) local a,b;\n b:= a+1;\n a:= x+1;\n \+ b;\n end: \nqproc(y);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,&%\"aG\"\" \"F%F%" }}}{PARA 0 "" 0 "" {TEXT -1 26 "Here is what happens when " } {MPLTEXT 0 21 8 "qproc(y)" }{TEXT -1 14 " is executed: " }}{PARA 15 " " 0 "" {TEXT -1 19 "First the argument " }{MPLTEXT 0 21 1 "y" }{TEXT -1 40 " is evaluated, and the formal parameter " }{MPLTEXT 0 21 1 "x" }{TEXT -1 37 " is replaced by the result (which is " }{XPPEDIT 18 0 "y " "I\"yG6\"" }{TEXT -1 39 ") throughout the body of the procedure." } {MPLTEXT 0 21 1 " " }}{PARA 15 "" 0 "" {TEXT -1 4 "Now " }{MPLTEXT 0 21 1 "b" }{TEXT -1 23 " is assigned the value " }{XPPEDIT 18 0 "a+1" " ,&%\"aG\"\"\"\"\"\"F$" }{TEXT -1 12 " (note that " }{MPLTEXT 0 21 1 "a " }{TEXT -1 39 " has no value other than itself yet). " }}{PARA 15 " " 0 "" {TEXT -1 5 "Then " }{XPPEDIT 18 0 "y+1" ",&%\"yG\"\"\"\"\"\"F$ " }{TEXT -1 30 ", which is the replacement of " }{MPLTEXT 0 21 3 "x+1 " }{TEXT -1 17 ", is assigned to " }{MPLTEXT 0 21 1 "a" }{TEXT -1 3 ". " }}{PARA 15 "" 0 "" {TEXT -1 28 "Finally, the local variable " } {MPLTEXT 0 21 1 "b" }{TEXT -1 35 " is evaluated one level (obtaining \+ " }{XPPEDIT 18 0 "a+1" ",&%\"aG\"\"\"\"\"\"F$" }{TEXT -1 26 "), but th e local variable " }{MPLTEXT 0 21 1 "a" }{TEXT -1 174 " is not further evaluated there. The value this local variable had is not lost (even though the procedure that owned it has terminated): we can have it ev aluated by using \"." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "\";" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,&%\"yG\"\"\"\"\"#F%" }}}{PARA 0 "" 0 "" {TEXT -1 284 "Under most circumstances we want the results our pr ocedures return to be fully evaluated, and not to contain local variab les. Careful consideration of the order in which assignments are made can usually remedy the situation. If necessary, you can fully evalua te an expression using " }{MPLTEXT 0 21 4 "eval" }{TEXT -1 47 ". Thus the procedure above could be rewritten:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "qproc2:= proc(x) local a,b;\n b:= a+1;\n a:= x+1;\n eval(b);\n end: \nqproc2(y);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#,&% \"yG\"\"\"\"\"#F%" }}}{PARA 11 "" 1 "" {TEXT -1 0 "" }}}{PARA 3 "" 0 " " {TEXT -1 0 "" }}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 9 "See also:" } {TEXT -1 1 " " }{HYPERLNK 17 "Assignments do not commute" 2 "Assignmen ts_do_not_commute" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "eval" 2 "eval" " " }{TEXT -1 2 ", " }{HYPERLNK 17 "Last name evaluation" 2 "Last_name_e valuation" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Local procedures don't a ccess local variables" 2 "Local_procedures_don't_access_local_variable s" "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 24 "Maple Advisor Database, " }{TEXT -1 15 " R. Israel 1997" }}}}{MARK "1 2 0" 164 }{VIEWOPTS 1 1 0 3 2 1804 }