-
-
Save CrypticSwarm/3291607 to your computer and use it in GitHub Desktop.
var optimist = require('optimist') | |
optimist.demand('color') | |
optimist.demand('size') | |
optimist.argv |
var optimist = require('optimist') | |
optimist.demand('color') | |
optimist.demand('size').argv |
I've seen effectively 0 valid use-cases for accessors. Things like ctx.fillStyle=
are just silly
plus .argv
could easily just be .argv()
here, I'm not bashing that API, I've used accessors plenty too, but IMO a language shouldn't even have them unless there's really a compelling reason, that's something I have yet to really see.
@rwldrn Agreed. However, it makes another thing that people need to keep in their minds if they copy something. Having a function (assuming it was bound to the correct object) that returned a value you could copy regularly. Not really arguing for or against, but this was something that made me do a double take when someone asked me about this situation.
Proxies will probably also have similar oddities that show up when people start making more use of them.
My thoughts are if you start using a language feature make sure you are aware of any nuances that might creep in.
If I understand the issue, the correct way to handle this is to get the source property descriptor and use it to define the new "copied" property with defineProperty. I usd that approach to create a "real clone" utility