I do not have a lot of time on my hands, but I thought I would share this project I spent some time on. It is in beta, report any problems you see!
That’s really complicated. I think it needs documentation! With examples. Especially to explain the “better” part. :~)
Have you read Chapter VIII of the manual? It’s probably not as featureful as your version, but it’s way simpler, especially for class/instance OOP.
I don’t mean to discourage you; I just really need to understand what problem you’re solving.
I honestly just want examples for each block. I’m not sure how to use them together.
@onu032001 has posted a great example! But I will get on the documentation/examples!
Sorry about that! (I didn’t have much time).
The project got corrupted. Working on it…
if you don’t mind me asking, how?
I think it’s a bug with saving expression blocks…
FINALLY Fixed… I’ll document it tommorow
Maybe a builder pattern would be nice? I.e.
I didn’t finish it because it wotn even create the instance (it returns false?)
You have to explicitly define the constructor. If I had to change the initialization, I would make it a reporter you drag onto the input slot (taking inspiration from the removed Cases library)
UPDATE: Checking for a class is now O(1) time complexity.
Edit: Nvm what I said earlier, I added this functionality
I don’t know why that’s still there. I was debugging
UPDATE: I have given every block a helpscreen.
Ah. Now that I understand the blocks I can argue with them. :~) Don’t take this lengthy message as discouragement; if I wanted to discourage you I’d just say “this is all wrong” and leave it at that! :~P
First, the help should be understandable by people who aren’t Java programmers. In particular, I don’t quite understand “private” vs. “static.” What I would expect “static” to mean is that the field can’t be changed once it has an initial value, e.g.,
![]()
You seem to be using “static” for class variables, which I think should mean that there is only one copy shared among all instances, not that the instances can’t access them! Why is that beneficial? The help for the IS block suggests that that’s how you make class variables, in which case I don’t understand how you make an instance variable!
As for “private,” I guess that comes from Java too. (I’ve read a Java manual but never programmed in it – too horrible to contemplate.) I would have expected it to mean that the field can’t be accessed from an object outside this class, or a non-object altogether, not that it can’t be accessed from a child class. When is that beneficial?
(I guess it’ll be obvious that I’m not convinced by the paranoia of the Java designers altogether. All else being equal, I think that we should follow the Scratch principle that if there’s something obvious for an expression to mean, it should mean that rather than throwing an error. I do mean the “all else being equal” part; I’d be happier if asking for item 0 of a list did throw an error, for example, because that’s a very common result of a missing base case in a recursive function. So I’m open to argument about why you think an error is better here.)
I don’t think the help texts explain enough. For example, the one for CLASS should say “Reports a new class, optionally (click the arrowhead) inheriting from another.” Otherwise it’s not clear how to specify the parent class, and it’s not clear what that arrowhead is good for. (You put scare quotes around ‘inheriting’ because you think users may not understand what that means, but you don’t explain what it means! This is a general design rule: Any time you find yourself using scare quotes, more documentation is needed.) Most of the blocks with arrowheads similarly need explanation in their help. The CLASS helpscreen in particular should be much longer, explaining what class/instance OOP means and why and how it differs from the prototyping inheritance that our users understand from the behavior of sprites.
By the way, I would argue for leftarrow ← rather than IS as the assignment operator. IS has the same problem as = for assignment in all those bad languages: It reads like it should be a predicate function, asking whether this is that rather than making it happen. (This mistake in the design of Fortran is, imho, the single worst design error in the history of computing.)
You copy-pasted the STATIC IS help text into STATIC METHOD, so the latter refers to “the field.” :~)
When I saw the RUN SUPER block, before I read its help I wondered what method of the parent it runs. The help seems to be saying that it runs the initialization method, but I don’t understand that restriction. If anything, I would expect it to run the parent’s method with the same name as the calling method in this object. But really I’d expect it to take an input with the method’s name. (And I’d expect there to be a CALL SUPER block for reporters.)
I would expect CLASS? applied to a non-object to report False rather than throwing an error.
![]()
In its help (and some others) you say “Returns if …” This should say “Reports True if …” (Otherwise it looks as if it throws an error if not.)
The help for (dark purple) OBJECT says “Reports an object, each of the key-value pairs.” That comma isn’t big enough to carry the weight you want it to. I (honestly!) thought that it meant “Reports a list of all the key-value pairs of the object,” i.e., reports the object, since that’s what an object (of this kind) is. You need to say something like “Takes a collection of key-value pairs as inputs, and reports an object with those as its fields.” I think this is especially important since the dark color of the block itself makes it easy to miss the black arrowheads. (Not your fault! A small Snap! UI mistake.)
I don’t understand what “raw objects” means in the category name. Do you mean prototypal objects that happen not to have parents? Or do these blocks also apply to magenta-colored-block objects?
The title text of the ✦⁺ PARENT block is confusing because elsewhere (as one learns by reading your code) you seem to use “✦⁺” for internal blocks not meant to be called by users. If it means something else, say so in the help.
Finally, it’s still not clear to me how and why these objects differ from the Snap! dictionary ones. Maybe I’m again asking you to explain the “better” in the name of this thread.
The help screens make it more confusing. I need examples.
‘✦⁺’ means magic method. I use $gears:: #000000 reporter to represent a helper method.
The keyword ‘static’ comes from JavaScript. I will change to ‘class method’ / ‘class field’ like python.
It creates a variable accesible but constant to all instances. You use SET.. TO in the Prototypical OOP & raw objects category to make an instance variable. I will add this in the helpscreen.
Yes, I meant they couldn’t be accessed, like encapsulation. The ‘no subclasses’ thing is because it takes inspiration from C++ fields. (Unrelated, maybe I should add a ‘protected fields’ block?)
LOL I’ve never used java.
Will do.
Also will do.
Technically no, but I meant ‘method’ instead of ‘field’.
True, but I think a name like ‘run super initialization’ would be too namely.
Noted.
Also noted.
I don’t recall why I put that there. Probably because they can be used as dictionaries, for traditional prototypical objects, and with class/instance objects.
It adds new functionality, like the IN and IS PROTOTYPE OF block.




