Why can the parameter names of a function be something outside the environment of the function?
Answer
the meaning of a function should be independent of the parameter names chosen by its author
Tags
#python #sicp
Question
Why can the parameter names of a function be something outside the environment of the function?
Answer
?
Tags
#python #sicp
Question
Why can the parameter names of a function be something outside the environment of the function?
Answer
the meaning of a function should be independent of the parameter names chosen by its author
If you want to change selection, open original toplevel document below and click on "Move attachment"
Parent (intermediate) annotation
Open it This principle -- that the meaning of a function should be independent of the
parameter names chosen by its author -- has important consequences for
programming languages. The simplest consequence is that the parameter names of a
function must remain local to the body of the function.<
Original toplevel document
1.3 Defining New Functions mplementer's choice of names for the function's formal
parameters. Thus, the following functions should provide the same behavior:
>>> def square(x):
return mul(x, x)
>>> def square(y):
return mul(y, y)
<span>This principle -- that the meaning of a function should be independent of the
parameter names chosen by its author -- has important consequences for
programming languages. The simplest consequence is that the parameter names of a
function must remain local to the body of the function.
If the parameters were not local to the bodies of their respective functions,
then the parameter x in square could be confused with the parameter x in
sum_squares . Critically,
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.