Gizmo, a happy little Rover from the tiny red planet called "Objectlins"
Say hello to Gizmo, a happy little Rover from the tiny red planet called "Objectlins" where you are not allowed to feed objects messages after midnight, and you most certainly are NOT allowed to get them wet. No one can handle that many instances running around.
Ever since Gizmo was instantiated, all 2.059 seconds ago, he has been responsible for managing 2 little objects. The thing he loves most about his job is being able to connect objects that work well together.
Gizmo could already tell that these two objects were going to accomplish great things. They were very respectful of each other and never asked for things that didn't belong to them. They also took each of their single responsibilities very seriously. They would never ask the other object to do their work for them. This was going to be an easy job for him.
The two objects in question are called North and Position. Each of them fit in a little drawer inside of Gizmo's chest, very close to his heart. If the requirements were different, he could have been managing any of North's friends. It wouldn't be too long before he'd get to meet them too though, unless the plans were to change. He loved a good plan change. Anything was possible with the right team of objects.
The label on North's drawer is marked with the word "Orientation". Gizmo wondered which Pen object wrote the label. The handwriting was very neat.
The orientation drawer itself was quite small, with room enough only for one. That was okay though, it wasn't meant to be a long-term dwelling. Objects never stayed long once they finished their job, they only had one thing to do after all.
Gizmo thought that for this project, the Orientation drawer was likely to only get three other visitors: East, South and West. If the circumstances required, the drawer would also welcome visits from NorthEast, NorthWest, SouthEast and SouthWest. A cheerful idea, but as it was, they didn't exist yet, and it wasn't certain that they would. Gizmo chuckled at himself, daydreaming again.
The position drawer also had a neatly written label, this time marked with the word "Position". If only he could write like that, but alas he was not a Pen object, but he was a happy little Rover object. This thought made him smile inside.
Oh yes, the position drawer. This also had enough room for one object at a time. Conveniently, this object shared the same name as the drawer, which would make finding it a much easier task for this little object. Wonderful. The turnover rate would likely be similar here too.
Gizmo especially liked knowing that the behaviour of the Position object and it's successors would be reliable. They always did the same thing. That being said, he could also appreciate the quirky nature of the orientation objects. They all did things a little bit differently, leaving their own mark on the same tasks.
FIRST MESSAGE RECEIVED
Gizmo was so excited for this project. He knew that any minute now the Translator object would send him a series of messages telling him what to do next. He hoped that he wouldn't be sent any messages that he couldn't understand. That would be a sad day.
To refresh his memory, Gizmo looked down at the three little envelopes attached below the orientation and position drawers. Each envelope represented a message that he could recieve.
If the name of the message recieved was the same as the name of one of his envelopes, then he would be able to open it up and follow the instructions inside it.
This was always an exciting moment for Gizmo, because he knew that the instructions were for his eyes only. No other object had access to them. It was kind of like ordering a Sushi object. You got to eat the delicious end result but don't get to see the mysterious workings behind how it was made in the Kitchen object.
Gizmo was gently shaken out of his happy little daydream about Sushi instances when a message envelope nudged him a couple of times. Suddenly he could barely contain himself. This was like a Christmas object. He quickly looked at the name of the message and to his absolute joy he saw that he did indeed understand this message.
Gizmo quickly opened up his left envelope. He could now get to work as a project manager, he knew exactly who to delegate the task of turning 90 degrees to the left to, and that was to the current occupant of his orientation drawer, North.
North recieves 'left' message
This was quite a nice place, North thought. The drawer was small but plenty of room for one. He remembered the last project he was a part of. He lived in a compass with all of his siblings and cousins. All he could remember was the smell of North-East's lazy susan (the spinny thing that let them all turn around). He didn't think he could eat tuna again after that.
North felt pretty happy with this new assignment. Things could get a little stale when you only had the one responsibility. So it was nice to get a change of scenery, to be a part of something a little different. This was a good life for a North object, even if he didn't really understand why his drawer didn't have his name on it. What did 'orientation' even mean?
It was at that moment that North heard a knocking sound. Suddenly his Heart object rate sped up, it had to be a message. Those were always exciting to recieve.
It was a message, and one he could understand at that. Fantastic! The message he recieved was called 'left'. So he opened his left envelope up. North already knew exactly what he had to do, but he still got a thrill reading the instructions that were a secret to everyone else.
North quickly made a phone call to his sister 'West'. It felt good for both of them to vent about NorthEasts lazy susan, and also for North to be able to accomplish his task so quickly.
He told West that it was time for her to return to the Rover. They both chuckled at that too. It was an inside joke that everyone in Objectlin was privy to, to return somewhere that you had never been before
So North put West into the empty 'left' envelope that the Rover sent him. Then he posted it back to the Rover. His job complete, he took one last look around the drawer and left. It was a shame he didn't have time to learn the Rover's name.
Gizmo meets West
Gizmo was excited to hear back from North, he couldn't wait to see what would get returned. He knew that North would have known exactly what to do with the message he sent.
The few milliseconds it took for the message result to be returned seemed like a lifetime, but it was definitely worth it to meet West. She told him all about her last assignment, but couldn't understand what she didn't like about the smell of tuna. His stomache grumbled as this reminded him about sushi objects again.
With West returned, Gizmo could complete his own left message by assigning West to the very same drawer that her brother North had just occupied. He was a happy little rover.
Another cool thing about having West stay in his drawer is that his wheels turned him so that he was pointing in the same direction as his name. It was like gaining superpowers.
West thought Gizmo was lovely, and she felt right at home in the drawer vacated the instant before she accupied it. It was pretty cool not having to wait for the room to be cleaned. The Sailor objects regularly complained about having to wait before checking into Hotel objects whenever the Ship object was being repaired.
Gizmo's second message
It wasn't too long before Gizmo recieved another letter. This one was carried to him by a little white Owl object. He'd have to ask the Translator object where he got it from, it was adorable.
Reading the label on the message, Gizmo felt like doing a happy dance, it just so happened to be his favourite message in the whole planet, 'forward'. This is the job that really made him shine as a project manager. Today was already shaping up to be the best day of his life and it was only day one!
It was time to put his team to work. If anyone were to look at Gizmo now they would see a change of energy. He was well known as a daydreamer who loved to imagine what it would be like to own a Sushi object Restaurant object. Right now however, he was completely focused. Not even a Sushi object could distract him out of his state of flow.
The first thing Gizmo did was take a little envelope out of the little cabinet found in the middle of his back. If anyone was watching, a serious little robot with his tongue sticking out trying to reach his back would have been pretty funny. Not that Gizmo would have noticed with all of that concentration.
Once he had retrieved the envelope, he knocked on Position's drawer and asked him if he was ready to be promoted to an argument role. Position loved it when he got to be an argument, especially when it meant he got to travel in a message envelope.
Gizmo then posted the letter into the tiny letter box that materialised on the orientation drawer. The label on the message he sent read 'forwardsOf:'. Then he waited patiently for the result, which was to become the new occupant of the position drawer.
Position's journey as an argument
Position had been enjoying his time in the position drawer. It was quite a nice room, one of the best he had stayed in so far. He wasn't sure how long he'd been there though, because he had fallen asleep to the comforting sound of ticking that came from Gizmo's heart.
The knock at his drawer door jolted him awake. He wasn't as young as he used to be, and didn't want anyone to think that he couldn't keep up with the newer instances when they came along.
Hastily opening the door, he was overjoyed to see an open message envelope sitting on Gizmo's open mechanical hand grabby things. As soon as he Gizmo mentioned the word argument he was on his way into the envelope. While the drawer was lovely, it was nothing compared to the first stamp experience of travelling inside a message. He heard they even had wifi on them now!
Settling into the single plush white armchair in the middle aisle of the envelope, he watched the flight attendant give safety instructions. They were pretty standard instructions, the PaperKnife object can be found under the Seat object in case of emergencies, keep your Seatbelt object on until the message has properly ascended or in the case of turbulance, and make sure that you fit your own OxygenMask object before other instance.
After takeoff, Position settled back into his chair with a EyeMask object to block out the light before falling asleep, ironically dreaming about the free wifi he wouldn't actually use.
It didn't take long for the message containing Position to land in the orientation drawer's letter box, and customs was smoother than usual.
West collaborates with postion
As West was thinking about Sailor objects complaining about the wait time at Hotel objects, she heard a familiar sound of rustling behind her.
The message envelope was thicker than usual, which meant only one thing, she was recieving an argument! Oh she just knew that this was going to be a fun job.
After a few milliseconds had passed, West realised that she was happy dancing and abruptly stopped. She didn't want to be the cause of any performance issues.
West instead decided to happy dance on the move, quickly making her way to the message and reading the label, which said "forwardOf: position".
Quickly looking down at the three envelopes she knew how to understand, she could confirm that this was indeed a responsibility she was able to fullfil, so she opened the message to see what was inside.
Almost like a Jack-in-a-box, position leaped out of the message envelope the moment it opened. This didn't phase West, she would have done exactly the same thing.
Both Position and West got a good impression of the other object. Every once in a rare while they encountered a defective object. Defective objects were the worst kind of objects, because they read your private messages without giving you a choice. Sometimes, they would even steal your job so you wouldn't even get a chance to work on a project at all. Which was like having the best kind of vacation taken away from you at the last mintue.
Luckily, both West and Position had well defined responsibilities. Neither of them would ask for what didn't rightly belong to them. This was going to be a fun collaboration.
The message that West received from Gizmo tells her to return the position that is directly in front of her.
If North were here, then the position that he would end up returning would be different, because the orientation determines what is in front. This is why Gizmo sent the message to West, because she has to let Position know who he is working with in order for him to be able to do his job.
All west needed to do was take out a little envelope and write her name with a lower case letter on it. She didn't know this, but Position knows how to accept messages for each of the four orientation objects that he knows about right now: north, east, south and west.
She sent her message to Position and waiting for him to return the result so that she could give it back to Gizmo.
Position receives West's 'west' message.
Gingerly taking the message that West just passed to him, Position looked carefully at the name to make sure he was about to carry out the right task.
It was his responsibility to find out what the position directly in front of West was. None of the other objects knew this, but position was really good at Math and always used it to help him carry out his tasks. He loved sending messages to number objects. He hoped that one day he would learn how to write more complicated Mathematical messages (as long as they were still simple to read).
The entire surface area of the planet Objectlin was covered by a fine grid of one by one squares. A Rover like Gizmo could navigate this grid by the help of his friends and collegues - the orientation objects and the position objects.
When Position was first assigned to Gizmo's position drawer, he came ready built with an x and y value. The x value represented one of the positions along the horizontal axis along the grid that covered the planet. The y value represented one of the positions along the vertical axis of the grid.
Position didn't know how big the grid was. He just knew exactly where he was on it. This made the problem of finding out what is directly in front of him pretty interesting, because he wasn't able to move himself. What he could do, was send a message to the class he was made from and tell it to create a new Position object directly in front of him.
So position took out two small white envelopes. Ordinarily, he would be estatic over getting to write so many messages, but this required a lot of concentration. He would celebrate later.
He addressed the first envelope to the his very own 'x' drawer, which would be received by the Number object that currently occupied it.
The message would be a simple '-' sign, and the envelope would contain another Number object that had a value of 1. This message would return a new Number object that contained the value of the Number contained in the 'x' drawer with 1 subtracted from it. This new Number would replace the current number occupying the x drawer.
The other message was addressed to his 'y' drawer, which would also be received by the Number object currently occupying it. The odd thing about this message is that it would end up replacing the current Number object occupying the y drawer, with another Number object with the exact same value as the old one.
Then Position tied those messages together and sent the bundle of two messages to the class object that he was made from. The class would create a new instance of Position with it's x and y drawers containing the Number objects given as arguments inside of the two bundled messages.
Finally, position would return this new object to West (who didn't even realise she was chatting to a different Position object).
West would then complete her own message by returning the new Position back to Gizmo.
Gizmo would then replace the current Position in his position drawer with the new Position that he had just been given. After doing this, he would find himself suddenly one square in front of where he was before, with a closer view of the Sushi object Restaurant object that he kept daydreaming about.
orientation ^ orientation .
position ^ orientation .
orientation: value orientation := value .
position: value position := value .
Class side initialization of state
position: coordinates orientation: direction ^ self new position: coordinates ; orientation: direction ; yourself .
left orientation := orientation left .
right orientation := orientation left .
forward position := orientation forwardsOf: position .
ORIENTATION OBJECTS: NORTH, EAST, SOUTH, WEST
left ^ West new .
right ^ East new .
forwardsOf: position ^ position north .
x ^ x .
x: value x := value .
y ^ y .
y: value y := value .
Class side initialisation of state
x: x y: y ^ (self new) x: x ; y: y ; yourself .
north ^ (self class: x: x y: y + 1) .
east ^ (self class x: x + 1 y: y) .
south ^ (self class x: x y: y - 1) .
west ^ (self class x: x - 1 y: y) .
Behaviour for testing
= other ^ ( x = other x) & ( y = other y ) .
printOn: aStream aStream nextPutAll: 'Position(' , x asString , ',' , y asString , ')' .