-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Objects #13
Comments
+1 for thingamajig 😂, we kind of have to decide how we want to implement objects. Do we want them like JavaScript objects / Python dictionaries? Or do we want them to be like C, Rust, Go structs? Or do we want them to be classes? Here are some examples: JS objs / Python dicts I RECKON nigel = THINGAMAJIG <
name: "Nigel",
age: 57
> C/Rust/Go structs, this would probably require a type system THINGMAJIG Person IS LIKE <
name IS A THINGY THAT YOU SAY
age IS A THINGY THAT YOU COUNT
>
I RECKON nigel = Person<
name: "Nigel";
age: 57;
>; |
Love Would be great to see these types for pattern matching:
|
It's worth noting that JavaScript itself has both. Although, classes in JS are a special type of function: // This modern syntax:
class C {
constructor() {
this.propertyName = 1;
}
methodName() {
alert('Hello!');
}
}
// Is roughly equivalent to this:
function C() {
this.propertyName = 1;
}
C.prototype.methodName = function methodName() {
alert("Hello!");
};
// In either case, you create one like this:
var obj = new C(); |
I just had an idea to emulate arrays as functions:
Sure enough, this prints out
You could probably do objects/dictionaries in much the same way. However, because of the way these are defined, I imagine they will take up a lot of memory after relatively few writes. |
Thingamejig is an object
Rustle up is the initiator
Buggered is the destructor
The text was updated successfully, but these errors were encountered: