callbyreference.docx
《callbyreference.docx》由会员分享,可在线阅读,更多相关《callbyreference.docx(11页珍藏版)》请在冰点文库上搜索。
callbyreference
[Savitch,p.137]Thecall-by-valuemechanismthatweuseduntilnowisnotsufficientforalltasksyoumightwantafunctiontoperform.Forexample,onecommontaskforafunctionistoobtainaninputvaluefromtheuserandsetthevalueofanargumentvariabletothisinputvalue.Withthecall-by-valueformalparametersthatwehaveuseduntilnow,acorrespondingargumentinafunctioncallcanbeavariable,butthefunctiontakesonlythevalueofthevariableanddoesnotchangethevariableinanyway.Withacall-by-valueformalparameteronlythevalueoftheargumentissubstitutedfortheformalparameter.Foraninputfunction,youwantthevariable(notthevalueofthevariable)tobesubstitutedfortheformalparameter.Thecall-by-referencemechanismworksinjustthisway.Withacall-by-referenceformalparameter,thecorrespondingargumentinafunctioncallmustbeavariable,andthisargumentvariableissubstitutedfortheformalparameter.Itisalmostasiftheargumentvariablewereliterallycopiedintothebodyofthefunctiondefinitioninplaceoftheformalparameter.Aftertheargumentissubstitutedin,thecodeinthefunctionbodyisexecutedandcanchangethevalueoftheargumentvariable.
Originalsentence:
Thecall-by-valuemechanismthatweuseduntilnowisnotsufficientforalltasksyoumightwantafunctiontoperform.
Extracomments:
Clause1:
Thecall-by-valuemechanismisnotsufficientforalltasks
Clause2:
that(=mechanism)weuseduntilnow
Clause3:
(that=tasks)youmightwantafunctiontoperform.
Analysis:
Clause1:
Thecall-by-valuemechanismisnotsufficientforalltasks
S+V:
Themechanismisnot
C:
Q:
E:
Themechanismisnotsufficient
C:
Q:
E:
Thecall-by-valuemechanismisnotsufficient
C:
Q:
E:
Thecall-by-valuemechanismisnotsufficientforalltasks
C:
Clause2:
that(=mechanism)weuseduntilnow
S+V:
weused
C:
Q:
E:
that(=mechanism)weused
C:
Q:
E:
that(=mechanism)weuseduntilnow
C:
Clause3:
(that=tasks)youmightwantafunctiontoperform.
S+V:
youmightwant
C:
Q:
E:
youmightwantafunction
C:
Q:
E:
(that=tasks)youmightwantafunctiontoperform.
C:
Finaltranslation:
TOP
Originalsentence:
Forexample,onecommontaskforafunctionistoobtainaninputvaluefromtheuserandsetthevalueofanargumentvariabletothisinputvalue.
Extracomments:
S+V:
onecommontaskis
C:
Q:
E:
onecommontaskforafunctionis
C:
Q:
E:
onecommontaskforafunctionistoobtainandset
C:
Q:
E:
onecommontaskforafunctionistoobtainaninputvalueandset
C:
Q:
E:
onecommontaskforafunctionistoobtainaninputvaluefromtheuserandset
C:
Q:
E:
onecommontaskforafunctionistoobtainaninputvaluefromtheuserandsetthevalueofanargumentvariable
C:
Q:
E:
onecommontaskforafunctionistoobtainaninputvaluefromtheuserandsetthevalueofanargumentvariabletothisinputvalue.
C:
Q:
E:
Forexample,onecommontaskforafunctionistoobtainaninputvaluefromtheuserandsetthevalueofanargumentvariabletothisinputvalue.
C:
Finaltranslation:
TOP
Originalsentence:
Withthecall-by-valueformalparametersthatwehaveuseduntilnow,acorrespondingargumentinafunctioncallcanbeavariable,butthefunctiontakesonlythevalueofthevariableanddoesnotchangethevariableinanyway.
Extracomments:
Clause1:
Withthecall-by-valueformalparametersacorrespondingargumentinafunctioncallcanbeavariable,
Clause2:
that(=call-by-value_formal_parameters)wehaveuseduntilnow,
Clause3:
butthefunctiontakesonlythevalueofthevariableanddoesnotchangethevariableinanyway.
Analysis:
Clause1:
Withthecall-by-valueformalparametersacorrespondingargumentinafunctioncallcanbeavariable,
S+V:
acorrespondingargumentcanbe
C:
Q:
E:
acorrespondingargumentcanbeavariable,
C:
Q:
E:
acorrespondingargumentinafunctioncallcanbeavariable,
C:
Q:
E:
Withthecall-by-valueformalparametersacorrespondingargumentinafunctioncallcanbeavariable,
C:
Clause2:
that(=call-by-value_formal_parameters)wehaveuseduntilnow,
S+V:
wehaveused
C:
Q:
E:
that(=call-by-value_formal_parameters)wehaveused
C:
Q:
E:
that(=call-by-value_formal_parameters)wehaveuseduntilnow,
C:
Clause3:
butthefunctiontakesonlythevalueofthevariableanddoesnotchangethevariableinanyway.
S+V:
butthefunctiontakesanddoesnotchange
C:
Q:
E:
butthefunctiontakesonlythevalueanddoesnotchange
C:
Q:
E:
butthefunctiontakesonlythevalueofthevariableanddoesnotchange
C:
Q:
E:
butthefunctiontakesonlythevalueofthevariableanddoesnotchangethevariable
C:
Q:
E:
butthefunctiontakesonlythevalueofthevariableanddoesnotchangethevariableinanyway.
C:
Finaltranslation:
TOP
Originalsentence:
Withacall-by-valueformalparameteronlythevalueoftheargumentissubstitutedfortheformalparameter.
Extracomments:
AissubstitutedforB的意思是A被用來取代B。
(主動語氣的說法是substituteAforB)
S+V:
onlythevalueissubstituted
C:
Q:
E:
onlythevalueissubstitutedfortheformalparameter.
C:
Q:
E:
onlythevalueoftheargumentissubstitutedfortheformalparameter.
C:
Q:
E:
Withacall-by-valueformalparameteronlythevalueoftheargumentissubstitutedfortheformalparameter.
C:
Finaltranslation:
TOP
Originalsentence:
Foraninputfunction,youwantthevariable(notthevalueofthevariable)tobesubstitutedfortheformalparameter.
Extracomments:
S+V:
youwant
C:
Q:
E:
youwantthevariable
C:
Q:
E:
youwantthevariabletobesubstituted
C:
Q:
E:
youwantthevariabletobesubstitutedfortheformalparameter.
C:
Q:
E:
youwantthevariable(notthevalueofthevariable)tobesubstitutedfortheformalparameter.
C:
Q:
E:
Foraninputfunction,youwantthevariable(notthevalueofthevariable)tobesubstitutedfortheformalparameter.
C:
Finaltranslation:
TOP
Originalsentence:
Thecall-by-referencemechanismworksinjustthisway.
Extracomments:
S+V:
Themechanismworks
C:
Q:
E:
Thecall-by-referencemechanismworks
C:
Q:
E:
Thecall-by-referencemechanismworksinthisway.
C:
Q:
E:
Thecall-by-referencemechanismworksinjustthisway.
C:
Finaltranslation:
TOP
Originalsentence:
Withacall-by-referenceformalparameter,thecorrespondingargumentinafunctioncallmustbeavariable,andthisargumentvariableissubstitutedfortheformalparameter.
Extracomments:
Clause1:
Withacall-by-referenceformalparameter,thecorrespondingargumentinafunctioncallmustbeavariable,
Clause2:
andthisargumentvariableissubstitutedfortheformalparameter.
Analysis:
Clause1:
Withacall-by-referenceformalparameter,thecorrespondingargumentinafunctioncallmustbeavariable,
S+V:
thecorrespondingargumentmustbe
C:
Q:
E:
thecorrespondingargumentinafunctioncallmustbe
C:
Q:
E:
thecorrespondingargumentinafunctioncallmustbeavariable,
C:
Q:
E:
Withacall-by-referenceformalparameter,thecorrespondingargumentinafunctioncallmustbeavariable,
C:
Clause2:
andthisargumentvariableissubstitutedfortheformalparameter.
S+V:
andthisargumentvariableissubstituted
C:
Q:
E:
andthisargumentvariableissubstitutedfortheformalparameter.
C:
Finaltranslation:
TOP
Originalsentence:
Itisalmostasiftheargumentvariablewereliterallycopiedintothebodyofthefunctiondefinitioninplaceoftheformalparameter.
Extracomments:
Clause1:
Itisalmost(sth=as_if...)
Clause2:
asiftheargumentvariablewereliterallycopiedintothebodyofthefunctiondefinitioninplaceoftheformalparameter.
Analysis:
Clause1:
Itisalmost(sth=as_if...)
S+V:
Itis
C:
Q:
E:
Itis(sth=as_if...)
C:
Q:
E:
Itisalmost(sth=as_if...)
C:
Clause2:
asiftheargumentvariablewereliterallycopiedintothebodyofthefunctiondefinitioninplaceoftheformalparameter.
S+V:
asiftheargumentvariablewerecopied
C:
Q:
E:
asiftheargumentvariablewerecopiedintothebody
C:
Q:
E:
asiftheargumentvariablewerecopiedintothebodyofthefunctiondefinition
C:
Q:
E:
asiftheargumentvariablewerecopiedintothebodyofthefunctiondefinitioninplaceoftheformalparameter.
C:
Q:
E:
asiftheargumentvariablewereliterallycopiedintothebodyofthefunctiondefinitioninplaceoftheformalparameter.
C:
Finaltranslation:
TOP
Originalsentence:
Aftertheargumentissubstitutedin,thecodeinthefunctionbodyisexecutedandcanchangethevalueoftheargumentvariable.
Extracomments:
Clause1:
Aftertheargumentissubstitutedin,
Clause2:
thecodeinthefunctionbodyisexecutedandcanchangethevalueoftheargumentvariable.
Analysis:
Clause1:
Aftertheargumentissubstitutedin,
S+V:
Aftertheargumentissubstituted
C:
Q:
E:
Aftertheargumentissubstitutedin,
C:
Clause2:
thecodeinthefunctionbodyisexecutedandcanchangethevalueoftheargumentvariable.
S+V:
thecodeisexecutedandcanchange
C:
Q:
E:
thecodeinthefunctionbodyisexecutedandcanchange
C:
Q:
E:
thecodeinthefunctionbodyisexecutedandcanchangethevalue
C:
Q:
E:
thecodeinthefunctionbodyisexecutedandcanchangethevalueoftheargumentvariable.
C:
Finaltranslation:
TOP