{VERSION 4 0 "IBM INTEL NT" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "Hyperlink" -1 17 "" 0 1 0 128 128 1 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" 0 21 "" 0 1 0 0 0 1 0 0 0 0 2 0 0 0 0 1 }{CSTYLE "Help Head ing" -1 26 "" 1 14 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 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 1 }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 1 }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 " "6#%\"yG" }{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" " 6#,&%\"aG\"\"\"F%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" "6#,&%\"yG\"\"\"F%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" "6#,&%\"aG\"\"\"F%F%" }{TEXT -1 26 "), but the \+ local variable " }{MPLTEXT 0 21 1 "a" }{TEXT -1 174 " is not further e valuated there. The value this local variable had is not lost (even t hough the procedure that owned it has terminated): we can have it eval uated 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 proc edures return to be fully evaluated, and not to contain local variable s. Careful consideration of the order in which assignments are made c an usually remedy the situation. If necessary, you can fully evaluate an expression using " }{MPLTEXT 0 21 4 "eval" }{TEXT -1 47 ". Thus t he 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%" }}}}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 9 "See also:" }{TEXT -1 1 " " }{HYPERLNK 17 "Assignments do not commute" 2 "Assignme nts_do_not_commute" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "eval" 2 "eval" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Last name evaluation" 2 "Last_name_ evaluation" "" }}}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 24 "Maple Advisor D atabase, " }{TEXT -1 15 " R. Israel 1997" }}}}{MARK "2 0 0" 0 } {VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }