scarpet icon indicating copy to clipboard operation
scarpet copied to clipboard

Adding Classes to scarpet.

Open Ghoulboy78 opened this issue 2 years ago • 7 comments

This is a continuation from this discord conversation, and the code I wrote there.

In this PR, I also rename heap.sc to min_heap.sc, and add max_heap.scl as a showcase of what could be done with classes.

NB: This PR should be Squashed and Merged, to avoid adding a bunch of useless commits to the history.

Todo:

  • [x] Examples, basically, in Readme.md

Ghoulboy78 avatar Apr 03 '22 11:04 Ghoulboy78

Why do you need to copy the class? 👀

BisUmTo avatar Apr 05 '22 11:04 BisUmTo

Because otherwise you end up just having 1 map and so one object, instead of multiple instances of the same class of object. Taking a copy means that the original is unchanged and the new_object method returns a separate map to the one we input. I came across this problem when rewriting matrix as a class to make it easier, and then realised that I was having this issue.

Ghoulboy78 avatar Apr 05 '22 15:04 Ghoulboy78

BTW Im working on inheritance rn. It's not too hard and I've got it mostly working already, just need to figure out whether inheriting a class which already inherits from another class works or not. Definitely parametric classes won't work (At least I think that's what they're called? I'm talking about things like class MyClass<A> or something like that)

Ghoulboy78 avatar Apr 07 '22 13:04 Ghoulboy78

Ok so I've finished inheritance. I will be adding extensive documentation to Readme.md cos currently it's got like 1 line tbh.

Ghoulboy78 avatar Apr 07 '22 13:04 Ghoulboy78

I'm going to make all classes have a couple fundamental methods, which I will put into an 'object' class

Ghoulboy78 avatar Apr 08 '22 10:04 Ghoulboy78

Still gotta figure out /script download stuff

Ghoulboy78 avatar Aug 09 '22 02:08 Ghoulboy78

Yeah, I don't think the /script download stuff is so important, I'm just gonna put this up for review as it is, cos other stuff depends on it.

Ghoulboy78 avatar Jan 23 '23 14:01 Ghoulboy78