Talk:Walnut/Ordinary Programming

From Erights

(Difference between revisions)
Jump to: navigation, search
(Random nonsense?)
Line 1: Line 1:
-
 
-
 
-
== Parameters implicitly defined by "var", not "def" ==
 
-
 
-
Where the article says:
 
-
<blockquote>Rather, they are true variables (implicitly declared with "def" )</blockquote>
 
-
 
-
Aren't they declared by "var"? You can modify them in the object's scope:
 
-
 
-
<pre>
 
-
def makeCar(var name) {
 
-
    var x := 0
 
-
    var y := 0
 
-
    def car {
 
-
        to moveTo(newX,newY) {
 
-
            name := "new name"
 
-
            x := newX
 
-
            y := newY
 
-
        }
 
-
        to getName() {return name}
 
-
    }
 
-
    return car
 
-
}
 
-
</pre>
 
-
 
-
<pre>
 
-
? def car := makeCar("a car")
 
-
# value: <car>
 
-
 
-
? car.getName()
 
-
# value: "a car"
 
-
 
-
? car.moveTo(1,2)
 
-
? car.getName()
 
-
# value: "new name"
 
-
</pre>
 
-
 
== Random nonsense? ==
== Random nonsense? ==
What is this stuff in the middle of the page? Image:http://i.imgur.com/bPaUV.png
What is this stuff in the middle of the page? Image:http://i.imgur.com/bPaUV.png

Revision as of 02:06, 5 December 2010

Random nonsense?

What is this stuff in the middle of the page? Image:http://i.imgur.com/bPaUV.png

Personal tools
more tools