Make E2 object-oriented (User defined classes) #2634
Replies: 6 comments
-
o'really. sure, you aren't the first nor the last one suggesting this. cough i think i know what is going to happen here: /thegrb93-post-link-to-starfall |
Beta Was this translation helpful? Give feedback.
-
E2 already has objects. If you're suggesting user defined objects then I guess that would be neat, but there's not really anyone willing to work on it. |
Beta Was this translation helpful? Give feedback.
-
It's on my mental task list that E2 should support user-defined types. This won't exactly be "object-oriented programming" in the sense that people often mean it - i.e. with inheritance and runtime polymorphism. At first it will likely look like simple record types: type person = { Name: string, Age: number } # example syntax, do not bikeshed here
function person:obituary(): string { # E2 already has method syntax, which would play nicely with record types!
return "Here lies " + Person.Name + ", who lived to the age of " + Person.Age
}
print(person("Methuselah", 969):obituary()) Then the next thing I want to do is add union types: type status = success | failure { Reason: string } # again, example syntax
function foo(): status {
return failure("You didn't bar the baz!")
}
function bar() {
switch (foo()) {
case success -> print("Hooray!")
case failure(Reason) -> print("Uh oh: " + Reason)
}
} Then this could go in a couple of different directions: static parametric polymorphism, Haskell-like typeclasses, and more. Of course, this will only happen if I have the time and motivation. If anybody wants to pay me to work full time on Wiremod then this'll happen faster! 😉 |
Beta Was this translation helpful? Give feedback.
-
So basically you are going to add javascript objects |
Beta Was this translation helpful? Give feedback.
-
No, I'm going to add Haskell objects 😄 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
[Suggestion] Make E2 object-oriented
againIts not a secret that currently the majority of people who program in E2 are those who have had lots of experience with it, and since they are more likely to program more complex programs, fir many it would've been much easier if e2 supported OOP practises.
I know some people went as far as to use tables as a workaround to make their code 'sort-of-object-oriented'
Beta Was this translation helpful? Give feedback.
All reactions