Diffrent languages has diffrent features about parsing parameters. There exists a lot of cofusion around this topic, especailly as people tends to use words like “parsing reference” and “parsing values” trying simplify the problem. Unfortunately, it only leads to more confusion. We need to understand the lower layer.
Java
- All are parsed by values.
- Eight primitive data types (
char, byte, short, int, long, float, double, boolean
) are saved in stack. When called, the value of the data is parsed. - Refrence data types (
object, array
) are saved in heap, referred by a address saved in stack. When called, the address value is parsed. - Special notice: a
String
, although being a object, can be viewed as same as ptimitive data type. Because the content in a String is immutable.
Python
- Mutable data type: list, dict and others are parsed by reference.
- Immutable data type: number, string and tuple type are parsed by value.
- …