Talk:Walnut/Ordinary Programming

From Erights

Revision as of 02:03, 5 December 2010 by (Talk)
Jump to: navigation, search

Parameters implicitly defined by "var", not "def"

Where the article says:

Rather, they are true variables (implicitly declared with "def" )

Aren't they declared by "var"? You can modify them in the object's scope:

 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
? def car := makeCar("a car")
# value: <car>

? car.getName()
# value: "a car"

? car.moveTo(1,2)
? car.getName()
# value: "new name"

Random nonsense?

What is this stuff in the middle of the page? Image:

Personal tools
more tools