4 ms·
If you really want to label: ellipse(65,50,60,60) Wouldn't using something like Python's keyword arguments better than some external labelling? ellip
by andybak 14y ago
If you really want to label:
ellipse(65,50,60,60)
Wouldn't using something like Python's keyword arguments better than some external labelling?
ellipse(radius_x=65, radius_y=50, center_x=60, center_y=60)
More characters but these are just training wheels. Once the learner understands the basics you can do away with them.
API's and libraries should be designed to allow both forms. Everyone is a beginner with some aspects of their craft. I'm a beginner when I use a library I'm not familiar with...
- msg 14y agoI personally like ellipse({axes: {horiz:65, vert:50}, center: {x:60, y:60}}) The function takes a specifiable object, and It's All JSON^tm. It also nests objects in objects in a satisfying, somewhat intuitive way. Argument keywords are not reified and don't require special forms. Instead, they just happen to be the labels of an object. I can see why you might not want to start with this concept for pedagogical reasons (you have to know a little about defining a Javascript object). But I would think you would want to move to this soon, so you can also get the programmer's special feeling of creating abstractions that make code disappear.
- tree_of_item 14y agoI think Bret made it pretty clear that these ideas are not training wheels. There's a section titled "These are not training wheels". The goal is not to do away with them but to make programming about them.
- andybak 14y agoHa. I didn't spot that bit... My point was though that allowing keyword and non-keyword forms is good for everyone. If you can't remember the parameter order you can just use the keywords (assuming the naming is memorable enough - which might actually be a can of worms in itself)
- Ygg2 14y agoNamed keywords help, but they don't give better overview of what each part represents. In other words they lower the barrier, but not by far (a novice programmer might still scratch his head and say... Radius what? of x? And why center y? Is x vertical? Or horizontal? from where do I calculate? ). However his examples do strike me as amazingly ambitious. How would one go around implementing a custom way to tell the application "Hey I'm width! And I'm height! Calculate us from this and that point!". I'd pay good money for someone to truly deliver on Victors ideas. LightTable might be a good start, but it's nowhere near even completeing 30% of ideas presented.