-
Notifications
You must be signed in to change notification settings - Fork 156
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
about Semiautovivification and f# cloning record implementation #53
Comments
You can use
in LiveScript. Semiautovivification is different, unlike the above if a property doesn't exist as an object or array it will make an empty one. As for the cloning with changing, you can do
Note that the JSON output you will see for personB on the site repl will only show the name, because JSON.stringiy does not show properties of the prototype, but personB does in fact have an age and a job, which you can access. |
how about adding an alias for for
then you could do:
this is actually very beautiful javascript, I much prefer it to trying to imitating classes |
I think than any feature than become more readable (even for person unfamiliar with the language) is a nice inclusion...."with" let a very readable code and understable for any people... |
@gkz would you accept a pull request implementing this above proposes infix |
Yes, as long as it doesn't break any existing code. |
The clone operator used to be postfix
Implying clone with
which corresponds well to this idiomatic Io code:
|
personA = name: \John, age: 20 personB = personA with name: \Amy personA.name == \John personB.name == \Amy personB.age == 20
Well screw it I was bored so I added it.
The only bad side affect is that you can't use a If we decide this is stupid I'll revert. |
well that's okay I guess. I started working on it, got the tokens->AST->JS process done without a hitch, but that's the easy part I guess because the grammar file and I were not making very good friends. Interestingly I was writing this comment and received a notification of your reply on the google group right before hitting "comment". I'll have to look at how you went about this so that I can contribute more effectively in the future. |
I'd be interested in seeing what you did, please post here with your work. edit: |
@gkz Maybe we can use do here too ? base-person =
name: \Person
job: \worker
old-person = base-person with age: 80
old-garry = old-person with do
name: \Garry
job: null Or maybe this would be better in the other construct ? with old-person do
@name = \Oldman |
@gkz oh noes, now you see my code that looks so long (and non-functional) relative to your 3-4 line solution. Also, what about partially applied infix @Nami-Doc I haven't pulled the new compiler yet, so I haven't tested it, but I'd assume that old-garry = old-person with do
name: \Garry
job: null would already be valid, and therefore be inconsistent to make it do something else. In any case, the old |
@Nami-Doc You can already add new properties, and use it with blocks (without |
Hi!!...first I wanna comment about the weird syntax for "Semiautovivification" (it's the first time than I heard that word :D)
I'm not sure cause the example wasn't totally clear for me...but is the same syntax for th coffeescript code
I feel it a bit complicate and weird compares with the coffeescript...the livescript syntax here offer any benefit?
the second point is abot cloning record..would be nice has cloning record in livescript
I don't know..but for me...this looks cool :D.....
maybe you know other cool way..please share your opinion.....
The text was updated successfully, but these errors were encountered: