NetLogo / LevelSpace

This is the LevelSpace extension repository. LevelSpace allows you to run NetLogo models |: from inside NetLogo models :|
Other
19 stars 8 forks source link

passing ls:let down through multiple levels #132

Open arthurhjorth opened 6 years ago

arthurhjorth commented 6 years ago

from our paper:

Importantly, ls:let exists in the context of a parent. This means that the value of a ls:let cannot be passed down through grand children without having to use ls:let again. I.e.

ls:let num-turtles count turtles
ls:ask 0 [
  ls:ask 0 [
    create-turtles num-turtles ;; WILL ERROR
    ]
  ]

Rather, the modeler would need to ask its child model to re-assign the ls:let in its own context, and then pass that into its own child model – the grandchild of the original model:

ls:let num-turtles count turtles
ls:ask 0 [
  ls:let child-num-turtles num-turtles
  ls:ask 0 [
    create-turtles child-num-turtles
    ]
  ]

Any way around this?

qiemem commented 6 years ago

I can think of a few things, but the need for it has never come up in practice. I would prefer to wait until we have real world examples of when its needed before deciding on a solution.

I don't think it actually needs to be addressed in the paper. I would just say "ls:let exposes data from the parent to the child." or something.

arthurhjorth commented 6 years ago

I can think of a few things, but the need for it has never come up in practice. I would prefer to wait until we have real world examples of when its needed before deciding on a solution.

For me it's really more about consistency in how we think of let and ls:let, which also gets at:

I don't think it actually needs to be addressed in the paper. I would just say "ls:let exposes data from the parent to the child." or something.

I definitely think it does. I think it will be confusing to anyone who doesn't know the implementation of ls:let + ls:ask or ls:of to understand why

let foo "bar"
ask turtle 0 [
  ask turtle 1 [
    show foo
    ]
  ]

works but

ls:let num-turtles count turtles
ls:ask 0 [
  ls:ask 0 [
    create-turtles num-turtles ;; WILL ERROR
    ]
  ]

does not. Don't you?

arthurhjorth commented 6 years ago

Btw, this isn't an argument for fixing this right this minute. But I do think this would be a nice fix down the road, and definitely should be in the paper.