Neighbours block not reporting neighbours

Report bugs. Post bug workarounds or fixes

Moderator: MSandro

Post Reply
SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Neighbours block not reporting neighbours

Post by SimpleSi » Jul 10th, '17, 14:48

Following other discussion I think I've nailed down what doesn't work for me that I think should

I think the first should give list <gpclass> and the 2nd should return list <arrowclass>

(using * for parameter works as expected - returns list <gpclass>)
0.png
0.png (11.13 KiB) Viewed 12210 times
1.png
1.png (11.33 KiB) Viewed 12210 times

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Neighbours block not reporting neighbours

Post by JohnM » Jul 10th, '17, 15:40

Ah! The instance that invokes "neighbors" (which is an instance of arrowclass) is not included in the result -- only other instances of its class. If you make another instances of arrowclass, neighbors will return a list with one arrowclass instance in it.

Note that the list contains references to the actual instances. One way to see that is to select "explore result" from the right-click menu on the "neighbors" block. You'll get a viewer on a list object. If you double-click on one of those instances, you'll get a viewer on the internals of that instance (with an arrow pointing to the visible instance on the screen). From this, you can that the instances have structure. If you instances have instance variables, you will see them in the viewer. Every visible object, such as instances of the classes the user creates, has a normally hidden instance variable called "morph" that holds the state used to display the object, keep track of parts if it is a composite object, and more. You're seeing the internal implementation details directly when you dig into morph. That's an invitation to dig deeper when they user is ready, but they can safely ignore what's inside the "morph" instance variable until that point.)

I hope I'm not dumping too much information on you!

SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: Neighbours block not reporting neighbours

Post by SimpleSi » Jul 10th, '17, 16:35

I can follow all the logic of that - I'll just have to stick with using its by expanding with black arrow to * to find neigbours

Having said that I follow it, I fail to understand why the default doesn't return ALL instances.

I'm thinking that GP has implict behaviour that doesn't match with my naive view of whats what :)

i'd argue, that as the simplest tool in the box, that my view should be the default behaviour :)

( and leave only finding other instances of the same class to advance/expanded use of the block )

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Neighbours block not reporting neighbours

Post by JohnM » Jul 10th, '17, 16:52

Hmm. I'd have expected that, by analogy with normal English usage, "neighbors" would not not include the person talking. That is, if I said "My neighbors are ..." I would list Debbie, Fernando, and Liz, but not myself.

But I could be wrong. As with all such design decisions, the real test is not what one or two people expect, but what the majority of typical users expect. I hope to gather more data about many design decisions over the next year.

It's possible that you're looking for a block that returns all the instances of a given class (regardless of where they are). There is such a block. It is called "all instances", but it's only available in developer mode because it can be bit tricky to use. It returns all instances of *any* class, not just user classes. That would include classes like "List", "Bitmap", and "String". The results can include instances that have been deleted from the stage but not yet garbage collected. (There is a "garbage collect" block in the same category as "all instances" (the "Debugging" category).

SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: Neighbours block not reporting neighbours

Post by SimpleSi » Jul 10th, '17, 17:03

Hmm. I'd have expected that, by analogy with normal usage, "neighbors" would not not include the person talking. That is, if I said "My neighbors are ..." I would list Debbie, Fernando, and Liz, but not myself.
I totally agree with that

To use a house analogy - the default is only reporting other people in the same house - not the list of neighbouring houses or occupants in those houses :)

But now I know - I can work with it - its a great feature BTW :)

SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: Neighbours block not reporting neighbours

Post by SimpleSi » Jul 10th, '17, 17:04

but it's only available in developer mode because it can be bit tricky to use
I think we all know it'll be a long time before I move up a class #PunIntended

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Neighbours block not reporting neighbours

Post by JohnM » Jul 10th, '17, 17:07

:-)

SimpleSi
Posts: 330
Joined: Jul 2nd, '17, 13:47

Re: Neighbours block not reporting neighbours

Post by SimpleSi » Jul 11th, '17, 16:25

OK this is what I think after a whole 24 hours :)

neighbours within (x)

return list of all instances within radius x

and

neighbours within (x) of class (y)

return list of all instances of class y within radius x

Post Reply