miscon:programming.functions.parameters-alias-arguments · draft · trust low · v0.1.1 · kind overgeneralization

Changing a parameter changes the caller's variable

A parameter is the same variable as the argument that was passed in, so assigning to the parameter inside the function changes the caller's variable, even for numbers and strings.

Stable URI
https://open-misconceptions.github.io/miscon-data/m/programming.functions.parameters-alias-arguments
UUID
7e500e88-daa7-49cb-a8f4-d0e0d6a62db0
Domain
programming.functions
Level band
secondary, undergraduate
Locale
en
About
https://open-misconceptions.github.io/miscon-data/c/programming.functions.parameter-passing (Miscon)

Evidence patterns

Pattern 0: trace a function that reassigns a primitive parameter

reports the caller's variable as changed

Itemdef bump(n): n = n + 1 x = 1 bump(x) print(x)
Expected1
Response2

Discriminators

vs a slip. Consistent across items with primitive arguments. A slip is a single wrong trace.

vs programming.functions.argument-name-must-match-parameter. Name-matchers predict errors when names differ; aliasers accept different names.

vs programming.objects.assignment-copies-object. The mirror: aliasers expect sharing where there is none; object-copiers expect independence where there is sharing. Test with a primitive item and a mutable-object item.

Relations

conflicts_with
Arguments are matched to parameters by position and copied in (external)
resolved_by
Arguments are matched to parameters by position and copied in (external)
Assignment copies a value into a variable at one moment (external)
confusable_with
programming.functions.argument-name-must-match-parameter

Provenance

Origin: llm-drafted

  1. Fleury, A. E. (1991). Parameter passing: The rules the students construct. In Proceedings of the 22nd SIGCSE Technical Symposium on Computer Science Education (SIGCSE '91), 283-286. doi:10.1145/107004.107066
  2. Madison, S., & Gifford, J. (2002). Modular programming: Novice misconceptions. Journal of Research on Technology in Education, 34(3), 217-229. doi:10.1080/15391523.2002.10782346
  3. Ma, L., Ferguson, J., Roper, M., & Wood, M. (2007). Investigating the viability of mental models held by novice programmers. In Proceedings of the 38th SIGCSE Technical Symposium on Computer Science Education (SIGCSE '07), 499-503. doi:10.1145/1227310.1227481

Drafted from the cited literature for the Open Misconceptions seed pack; statement, examples and discriminators are original text. Awaiting maintainer review.

Review status

Status draft, trust low (computed from the reviews below against the reviewer registry).

No reviews yet.

Formats

Cite

miscon:programming.functions.parameters-alias-arguments
https://open-misconceptions.github.io/miscon-data/m/programming.functions.parameters-alias-arguments