Symbol optimizations (Mainly for developers)

I created a block which changes a huge switch case block (the one that tells which symbol to render, which is 7,320 characters long) into a smaller size (280 characters, 26% the original size)!

Doing this also makes it easier for developers to make more symbols, since they don't need to edit the huge switch block. They only need to push the symbol name to SymbolMorph.prototype.names and they have to add the function. :slight_smile:

I think Jens is on vacation so you may not get a reply right away.

I know. I just wanted to show something off. Of course, not everything will be accepted. :slight_smile:

I don't think you realize this, but there are some symbols that don't have the same name and function name, or multiple symbols use the same function, but different widths. The reason why this is important, is that it's more of a hassle to remember to use the same symbol name in the function.

A better system would be to create a giant dictionary, which contain the name of the symbol, and also the function, but that's also very similar to the current giant if statement anyway, so it's not really needed.

I don't think you understand what .prototype actually is. In javascript, if you define a method or variable on an object in .prototype, it gives access to that thing when you create a new object using new SymbolMorph().

The variable names in snap are already very well written, and .prototype is a lot more important than you think. Not to mention, I've learned that using abbreviations come at the cost of not really understanding what they are later, or to someone reading your code. It's best to use the full name of something, or use abbreviations sparingly. Plus, a programming IDE already shows you a list of variable names as you start typing, which you can hit enter to auto fill, so most of the time, you don't even need to type the full name.

P.S.

I'm pretty sure when jens comes back from vacation, he'll yell at you to not post this kind of stuff on the forum, and about users thinking they know what they're doing when it comes to the snap source code.

I'm just warning you, ok?

I deleted it. :slight_smile:

I created this as a library. With this you can do this cool thing:

styledLetterA
loadantimods
Of course Antidefinitive is not yet a mod here. But I am going to think about it! :laughing:

This expects you to know how symbols work, so you should definitely look in the files to teach yourself.