-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
How to work with objects? #20
Comments
Hi there, Good question! Objects currently share the same interface as Arrays (
I know! the above is not intuitive and somewhat confusing. I'm considering about separating Objects from Arrays and give them a good name like Another good question is whether or not to bring more sophisticated OOP into wenyan, such as classes, inheritance, constructors, etc. I'll need to think more about that. Thanks! |
One more question, how do you identify an object from an array? AFAIC, |
That's correct, you cannot tell Array from objects in my current implementation. But as I mentioned I'm considering adding real objects to the language, keep tuned :) |
Suggestion for object syntax:
Compiles to: var DUI4XIANG4 = {
JIA3: 3,
YI3: "噫吁戲",
BING3: false
};
console.log(DUI4XIANG4);
console.log(DUI4XIANG4.JIA3); |
@yyx990803 Nice! I like it very much |
I think we may need a
compiles to delete DUI4XIANG4.JIA3; BTW, will we consider add a |
@rikakomoe These suggestions are all great, thanks. Will incorporate. Also, adding link here to a related proposal about supporting classes, as a reference: |
Hi everyone! Object literals are here! Inspired by @yyx990803 and @rikakomoe 's suggestions, the basic syntax is like this:
Compiles to
Classes are not added yet, but now you can simulate them with "factory" style:
... and a bit of The
A new example containing all the above is added to There might be some minor bugs with the implementation as it was freshly made, Please let me know if you find any bugs! Regarding the design, I'm also open to changes if you can convince me ;) Thank all of you again for the proposal. Let me know what you think. If this one goes down well my next step is to implement import statements. Stay tuned! |
|
古有一道法、以一物照一物、謂之曰「射」。 凡變數以「射」為原型者、謂之曰「對象」。 今有程序員者一人、遍讀此作而不知「對象」應作何書、方前來求問。
The text was updated successfully, but these errors were encountered: