When explaining something to another person, shouldn’t you use clear terms? Shouldn’t you want to recognize what the other person already knows?
“One of the very useful aspects of Python is the concept of collection (or container) types. In general a collection is an object that contains other objects in a way that is easily referenced or indexed.”
http://en.wikipedia.org/wiki/Python_syntax#Collection_typesNotice that “container” is used to define collection. Some of these collection containers: lists, tuples, and strings.
With this well-known picture of "collections", my VM program does not contain .vm files. The .vm files are separate ‘animals in a separate barn’; they reside in completely different paths.
Yes, I agree, a procedural/OO program is a collection of functions, starting with “main”. And there may be multiple program files, with their unique file extension (e.g.,.py).
But the book says a "VM program is a collection of one or more .vm files, each containing one or more VM functions, each being a sequence of VM commands."
ybakos wrote
Take a look at some of the .vm files in the project toolkit. Search for the word "function".
If I understand you correctly (.vm files in the project toolkit), here is the first one, simpleAdd.vm:
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/07/StackArithmetic/SimpleAdd/SimpleAdd.vm
// Pushes and adds two constants.
push constant 7
push constant 8
add
Where is the word “function”?
Here is the second, StackTest.vm:
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/07/StackArithmetic/StackTest/StackTest.vm
// Executes a sequence of arithmetic and logical operations
// on the stack.
push constant 17
push constant 17
eq
push constant 892
push constant 891
lt
push constant 32767
push constant 32766
gt
push constant 56
push constant 31
push constant 53
add
push constant 112
sub
neg
and
push constant 82
or
Where is the function?
If I can’t see the function, how can I understand the other statement on page 141
"The order of the functions within the .vm files does not matter."?
Where in the book does it explain these functions that are in the .vm files?
The word is used in Figure 7.6 The memory segments seen by every VM function.
And Figure 7.7 includes this: “VM files (f = VM function)”
But no examples are provided.
Again, when explaining new concepts, shouldn’t you provide examples?
Is the VM “function” different than a Python “function”?
How is a VM “command” related to a VM “function”? They cannot be the same; doesn't the order of VM commands matter? Would this sequence be valid for SimpleAdd.vm?:
push constant 7
add
push constant 8
The statement "Recall that a VM program is a collection of one or more .vm files, each containing one or more VM functions, each being a sequence of VM commands." is still a mystery. I cannot recall something that didn't happen.