Class based AND Prototype based object mod

<blocks app="Snap! 5.4, http://snap.berkeley.edu" version="1"><block-definition s="found? %&apos;aaa&apos;" type="predicate" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportNot"><block s="reportListIsEmpty"><block var="aaa"/></block></block></block></script></block-definition><block-definition s="assoc %&apos;key&apos; %&apos;a-list&apos;" type="reporter" category="lists"><comment x="0" y="0" w="289.3333333333333" collapsed="false">The second input is an &quot;association list,&quot; a list of two-item lists.  Each of those smaller lists has a &quot;key&quot; as its first item and a &quot;value&quot; as its second.  ASSOC reports the first key-value pair in the association list whose key matches the first input.</comment><header></header><code></code><translations>ca:associació _ _&#xD;</translations><inputs><input type="%s"></input><input type="%l"></input></inputs><script><block s="doIf"><block s="reportListIsEmpty"><block var="a-list"/></block><script><block s="doReport"><block s="reportNewList"><list></list></block></block></script></block><block s="doFor"><l>i</l><l>1</l><block s="reportListLength"><block var="a-list"/></block><script><block s="doIf"><block s="reportEquals"><block s="reportListItem"><l>1</l><block s="reportListItem"><block var="i"/><block var="a-list"/></block></block><block var="key"/></block><script><block s="doReport"><block s="reportListItem"><block var="i"/><block var="a-list"/></block></block></script></block></script></block><block s="doReport"><block s="reportNewList"><list></list></block></block></script></block-definition><block-definition s="insert %&apos;name&apos; %&apos;value&apos; into %&apos;table&apos;" type="command" category="lists"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>kv-pair</l></list></block><block s="doSetVar"><l>kv-pair</l><custom-block s="assoc %s %l"><block var="name"/><block var="table"/></custom-block></block><block s="doIfElse"><custom-block s="found? %l"><block var="kv-pair"/></custom-block><script><block s="doReplaceInList"><l>2</l><block var="kv-pair"/><block var="value"/></block></script><script><block s="doInsertInList"><block s="reportNewList"><list><block var="name"/><block var="value"/></list></block><l>1</l><block var="table"/></block></script></block></script></block-definition><block-definition s="%&apos;a&apos;" type="predicate" category="other"><header></header><code></code><translations></translations><inputs><input type="%mult%cs"></input></inputs><script><block s="doReport"><block var="a"/></block></script></block-definition><block-definition s="delete %&apos;key&apos; from %&apos;table&apos;" type="command" category="lists"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%l"></input></inputs><script><block s="doFor"><l>index</l><l>1</l><block s="reportListLength"><block var="table"/></block><script><block s="doIf"><block s="reportEquals"><block s="reportListItem"><l>1</l><block s="reportListItem"><block var="index"/><block var="table"/></block></block><block var="key"/></block><script><block s="doDeleteFromList"><block var="index"/><block var="table"/></block><block s="doStopThis"><l><option>this block</option></l></block></script></block></script></block></script></block-definition><block-definition s="clone of %&apos;parent&apos;" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%cmdRing"></input></inputs><script><block s="doDeclareVariables"><list><l>self</l><l>methods</l><l>data</l></list></block><block s="doSetVar"><l>methods</l><block s="reportNewList"><list></list></block></block><block s="doSetVar"><l>data</l><block s="reportNewList"><list></list></block></block><custom-block s="insert %s %s into %l"><l>set</l><block s="reifyScript"><script><custom-block s="insert %s %s into %l"><block var="name"/><block var="value"/><block var="data"/></custom-block></script><list><l>self</l><l>name</l><l>value</l></list></block><block var="methods"/></custom-block><custom-block s="insert %s %s into %l"><l>method</l><block s="reifyScript"><script><custom-block s="insert %s %s into %l"><block var="name"/><block var="value"/><block var="methods"/></custom-block></script><list><l>self</l><l>name</l><l>value</l></list></block><block var="methods"/></custom-block><custom-block s="insert %s %s into %l"><l>clone</l><block s="reifyScript"><script><block s="doReport"><custom-block s="clone of %cmdRing"><block var="self"/></custom-block></block></script><list><l>self</l></list></block><block var="methods"/></custom-block><custom-block s="insert %s %s into %l"><l>delete var</l><block s="reifyScript"><script><custom-block s="delete %s from %l"><block var="name"/><block var="data"/></custom-block></script><list><l>self</l><l>name</l></list></block><block var="methods"/></custom-block><custom-block s="insert %s %s into %l"><l>delete method</l><block s="reifyScript"><script><custom-block s="delete %s from %l"><block var="name"/><block var="methods"/></custom-block></script><list><l>self</l><l>name</l></list></block><block var="methods"/></custom-block><custom-block s="insert %s %s into %l"><l>parent</l><block var="parent"/><block var="data"/></custom-block><block s="doSetVar"><l>self</l><block s="reifyScript"><script><block s="doDeclareVariables"><list><l>kv-pair</l></list></block><block s="doSetVar"><l>kv-pair</l><custom-block s="assoc %s %l"><block var="message"/><block var="methods"/></custom-block></block><block s="doIf"><custom-block s="found? %l"><block var="kv-pair"/></custom-block><script><block s="doReport"><block s="reportListItem"><l>2</l><block var="kv-pair"/></block></block></script></block><block s="doSetVar"><l>kv-pair</l><custom-block s="assoc %s %l"><block var="message"/><block var="data"/></custom-block></block><block s="doIf"><custom-block s="found? %l"><block var="kv-pair"/></custom-block><script><block s="doReport"><block s="reifyReporter"><autolambda><block s="reportListItem"><l>2</l><block var="kv-pair"/></block></autolambda><list><l>self</l></list></block></block></script></block><block s="doIf"><block s="reportIsA"><block var="parent"/><l><option>command</option></l></block><script><block s="doReport"><block s="evaluate"><block var="parent"/><list><block var="message"/></list></block></block></script></block><block s="doReport"><block s="reportNewList"><list></list></block></block></script><list><l>message</l></list></block></block><block s="doReport"><block var="self"/></block></script></block-definition><block-definition s="new object" type="reporter" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doReport"><custom-block s="clone of %cmdRing"><block s="reportNewList"><list></list></block></custom-block></block></script></block-definition><block-definition s="tell %&apos;object&apos; %&apos;message&apos; %&apos;args&apos;" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%repRing"></input><input type="%s"></input><input type="%mult%s"></input></inputs><script><block s="doRun"><block s="evaluate"><block var="object"/><list><block var="message"/></list></block><block s="reportCONS"><block var="object"/><block var="args"/></block></block></script></block-definition><block-definition s="ask %&apos;object&apos; %&apos;message&apos; %&apos;args&apos;" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%repRing"></input><input type="%s"></input><input type="%mult%s"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="evaluate"><block var="object"/><list><block var="message"/></list></block><block s="reportCONS"><block var="object"/><block var="args"/></block></block></block></script></block-definition><block-definition s="comment %&apos;obj&apos;" type="command" category="other"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs></block-definition><block-definition s="class %&apos;a&apos; %&apos;type&apos;" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%cmdRing"></input><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>j</l></list></block><block s="doSetVar"><l>j</l><block var="type"/></block><block s="doReport"><block s="reifyScript"><script><block s="doIf"><block var="a"/><script><block s="doReport"><block var="j"/></block></script></block><block s="doReport"><custom-block s="clone of %cmdRing"><block var="a"/></custom-block></block></script><list><l>a</l></list></block></block></script></block-definition><block-definition s="instance %&apos;obj&apos;" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%cmdRing"></input></inputs><script><block s="doReport"><block s="reportIfElse"><block s="evaluate"><block var="obj"/><list><l>hello world</l></list></block><block s="evaluate"><block var="obj"/><list><l></l></list></block><custom-block s="error %s"><l>Whoops</l></custom-block></block></block></script></block-definition><block-definition s="error %&apos;a&apos;" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>a</l></list><l>return new Error(a)</l></block><list><block var="a"/></list></block></block></script></block-definition></blocks>

wow, that's really good

love this block
untitled script pic (10)

Why don't you just share a project with the blocks?

Oh,I forgot.XD :sweat_smile:

That is just for commenting all module blocks.You should have it on top of your modules and throw every custom block on it.I thought you liked the(class of ())and(instance of ())and(clone of ()).These are the core of this mod.

I didn't understand most of the blocks

Have you read the manual?Turn to page 71

nope, I don't bother with manuals when coding, I figure it all out by myself

That works if the language you're learning is exactly like the last language you learned, e.g., you learned Java and now you're learning Python or vice versa. But if the language you're learning has ideas you haven't seen before, like for example closures (a/k/a gray rings), it's a good idea to read at least that part of the manual. Imho.

ok, sorry, I meant that I don't bother with the snap marual, if I'm learning a new language, I\de read the manual, also I came from scratch so I know a lot about how to code in snap (I also figure things out)

But the beginning of this little conversation was you saying you didn't understand. So reading (at least that part of) the manual seems like a good idea. :~)

P.S. This has nothing to do with the fact that I wrote it! ;~P

stufftokeepthistopicactive

So.
After two years,i had to review this topic due to bh telling me to make a parse class in snap
This is what i found out:

  1. Sharing a xml is really inconvenient so there you go:obj(ps:the fraction class is a wip so it doesn't work at all)
  2. Objects are really useful so jens should not add them.Instead let newcomers make them for a good lesson(with the ignore block too)and objects are worth a chapter of manual(chapter viii i remember)

Nice. The help is a little cryptic, especially for NEW OBJECT. :~P

It is a 2-year old project and i haven't learned to be nice and not say "stupid"then

this is gold:
Screen Shot 2022-03-30 at 11.29.42 PM

my favorite part is

...aluated).(Command(C Shape)...

where you closed up some parenthesis put a period immediately opening up another parenthesis crushing that period, and not to slow down there no you went ahead and started nesting your clarifications, plus the bold font and lack of spacing its just too good