scarpet
scarpet copied to clipboard
Adding Classes to scarpet.
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
Why do you need to copy the class? 👀
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.
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)
Ok so I've finished inheritance. I will be adding extensive documentation to Readme.md cos currently it's got like 1 line tbh.
I'm going to make all classes have a couple fundamental methods, which I will put into an 'object'
class
Still gotta figure out /script download stuff
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.