Some thoughts from a self directed learner

Observations from leading GP activities

Moderator: MSandro

Post Reply
Posts: 7
Joined: Oct 5th, '17, 16:26

Some thoughts from a self directed learner

Post by vickiS » Jan 9th, '18, 23:21

I'm the only participant so far in a self directed project but my son has expressed an interest in GP Blocks so I'm hoping to work with him on that. I have used Scratch, Snap, Squeak and Etoys before and that has been helpful but it still took me some time to grasp a few things. Many of these things should have been obvious to me and I'm not exactly sure why they weren't. I'm not blaming GP Blocks for this. It's more likely a lack of patience, experience and general comprehension on my part. These are some revelations that got things clicking for me. Or at least avoiding the debugging window.

Thinking in terms of objects representing results and not values. This seems so elemental but I still try to assign string 'true' when I mean boolean expression (true). I spent a bit of time exploring variable assignment and side effects and that really helped firm up my thoughts. For objects like Integer, Float or Boolean you can't change the result without generating a new object so even if you assign one to variable 'a' and explicitly assign variable 'a' to variable 'b' there is nothing you can do to 'a' that affects 'b'. String is special because strings are immutable and can represent named objects but the same holds. Variable 'a' does not affect variable 'b'. However, depending on methods used, it is possible to change the results of data objects like array, dictionary, list and table without creating new objects. If variable 'a' is assigned a list and then explicitly assigned to 'b', 'a' will affect 'b'. To preserve 'a' I need to generate another list with the same result or make a copy of 'a' to assign to 'b'. Color is interesting because transparency is set to 255 by default. The same rgb values result in the same color. I can change the transparency value using a method block (found in color class browser) but this will affect variable 'b' whether its been explicitly assigned to variable 'a' or not. I can't think of a circumstance where I would assign multiple instance variables the same color and then decide only one of them should have transparency but it's interesting to know. I'm not sure if I know precisely what I mean by same and different here but I concluded that it's possible for two different objects to represent the same result but the same objects cannot represent two different results if that makes any sense.

Input boxes will accept any round block. Whether it makes sense or will result in an error is a different matter. The boxes do offer clues as to what should go in them but it took me an embarrassingly long time to realize I could drop lists on boxes with drop downs as long as the list is comprised of the appropriate class objects. This sure made frame animation less tedious. I also discovered that I could make custom key handlers by dropping a character code block on the key is down block so not necessarily restricted to the keys in the list except for keys like escape that are reserved for the project editor. I was experimenting with a Steam game controller in lizard mode (Steam not running). Windows sees it as a mouse/keyboard input device but the mappings are very limited. It worked fine with a really simple arcade type game though.

Instance methods require a class instance object as a parameter. This is evident just looking at the block palette. But forming this sentence in my head helped me finally understand how to use the action method block. It's the only way to use a custom instance method as a first class object. To give an example if I wrap myCustomBlock with a function block, the function can't see instance variable 'this'.

customblock.png (6.25 KiB) Viewed 2548 times
This does not work:
callfunction.png (8.68 KiB) Viewed 2548 times
The action block binds instance variable 'this' to named instance method myCustomBlock and can be used as any other object. I can add as many parameters as required by the instance method. I hope I am articulating this properly.
This works:
callaction.png (8.54 KiB) Viewed 2548 times

I've caused myself a lot of trouble assigning class object instances to variables and then deleting them. This is due to being lazy and not writing proper scripts. I would just press the clear button and carry on. I am not sure why I thought the variable would automatically set itself to nil or empty string but I certainly wasn't paying attention until I generated errors I couldn't recover from. Now I know that the delete block merely removes objects from the stage. If an object is still assigned to a variable it still exists in memory and will hang around like a ghost. Other objects on the stage will continue to see it and interact with it. So now I remember to explicitly reassign the variable when I remove named objects.

I also spent too much time pondering discrepancies between the block display string and the results window. How does a Color get auto magically converted to Gray? And other such questions. As usual the answer is in the system browser. Just about every class has a toString method and a block display will use that or the Class toString method which prints the name of the class and wraps it in angular brackets. So I believe angular brackets are just informative and I no longer need to worry about what <Morph myClass> should mean to me. I think. I do really appreciate that GP Blocks provides all the tools one needs to explore and understand the language.

Overall I have been getting along well with the project editor. I have developed some wishes. It would be nice to have an easy way to create costume lists. I can use keyboard short cuts to copy costume names in the image panel and paste them into blocks in the script editor which helps. I also wonder if there could be an intermediate step in end user mode such as a class browser restricted to the classes of objects generated by global functions in the blocks palette. The objects and their methods are dispersed throughout the palette and it might be nice to have an organized reference to them without going into developer mode. I don't know if that would just cause more confusion but it could help understanding common errors.

NotePad++/Gedit and GP Blocks have already replaced several heavyweight tools I have been using with csv data. Now that I understand a little better how I can be the cause of my own misfortune I anticipate using this application often going forward.

Post Reply