Comments (6)
thanks for these comments, this is very helpful
from learningprocessing.
Ok, I am finally getting around to these fixes. I like the idea of a sidebar but managed to squeeze the chapter 8 section into one paragraph which now reads:
In #functions, we showed how when a primitive value (integer, float, etc.) is passed in a function, a copy is made (known as pass by value. With objects, this is not the case, and the result is a bit more intuitive. If changes are made to an object after it is passed into a function, those changes will affect that object used anywhere else throughout the sketch. In Java, this is strangely still an example of pass by value, the difference is that a copy of a reference to the object is passed rather than a copy of the object itself. You can think of a reference as the address in memory where the object's data is stored. So while that address is copied there is still only one object and so any changes to that object affect both variables.
@ybakos would love any thoughts on the above if you have a minute! Closing this issue for now.
from learningprocessing.
"With objects, this is not the case..."
I would change that to say something besides "this is not the case," because the following sentences contradict that. (Reader: Uh... so is it the case or is it not the case?)
Maybe just something like:
In #functions, we showed how when a primitive value (integer, float, etc.) is passed to a function, a copy of the value is made (known as pass by value_)_. With objects, this process is less intuitive.
from learningprocessing.
Ok, rewritten again now:
In #functions, we showed how when a primitive value (integer, float, etc.) is passed in a function, a copy of the variable is made and the original variable remains the same no matter what happens in the function. This is known as pass by value. With objects, things work a bit differently. If changes are made to an object after it is passed into a function, those changes will affect the original object. Instead of copying the object and passing it into the function, a copy of a reference to the object is passed rather. You can think of a reference as the address in memory where the object's data is stored. So while there are in fact two distinct variables holding on their own value, that value is simply an address pointing to only one object. And so any changes to that object affect both variables.
I am also going to add a diagram which I think will help make it more clear.
from learningprocessing.
That's pretty good! Two minor quibbles:
- first sentence: passed into a function (same as in the remainder of the paragraph)
- delete "rather"
from learningprocessing.
Thanks, changed!
from learningprocessing.
Related Issues (20)
- Exercise 1-2: Solution missing/unclear
- Example 19-6/Exercise 19-5: ellipse() doesn't work in clientEvent HOT 1
- 07-08 Fahrenheit HOT 5
- solution for exercise 7.2 calling a function
- The function "printIn()" does not exist
- no answer for exercise 19- 6
- the gravity ball is shaking, Is that because of the precision of float? HOT 2
- Example14-14 Need download "Camara 3D" Libarary File?
- In Example21-4, What library I need to import?
- Repo for Copy Errors? HOT 2
- Page 43 Errors
- Lorentz attractor code not working properly. Issue with peasy HOT 1
- Figure 1-11
- Error generated from running example 14-3
- error on Page 258
- Figure 1-21
- Origin of "bug"
- Grace Hopper's story isn't apocryphal
- Formatting error
- Please ad code for Exercise 14-5 !
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from learningprocessing.