3 ms·
If you want to show off how simple your API is then I can think of several things that would improve clarity: 1. Don't use parentheses in comments. They make t
by andybak 6y ago
If you want to show off how simple your API is then I can think of several things that would improve clarity:
1. Don't use parentheses in comments. They make things more visually confusing when javascript imposes enough syntactic clutter as it is.
2. What's with /* */ ? Doesn't js allow keyword arguments?
3. Your method names are probably a little short for my taste. I'd be happier with sequence() and parallel() instead of seq() and par(). Par especially seems a little too obscure when first encountering it.
4. "cx = location | cr = radius" - why not allow both forms? - or just the clearer one rather than the shorter one.
- gcb0 6y ago> 2. What's with /* */ ? Doesn't js allow keyword arguments? No.
- andybak 6y agoI couldn't remember if that was one of the things they fixed with ES6. I wonder if passing in a dict is a good alternative in this case. More syntax clutter but at least the params have some semantic meaning.
- randallsquared 6y agoObject destructuring in the parameter list comes very close to supporting keyword arguments, with only a couple of characters overhead.
- carc1n0gen 6y agoRe: #2, it does not
- bmn__ 6y agoThread neighbour gcb0's answer is censored by Hackernews. (Turn on the showdead setting in your profile to see it.) I want to answer, but I can't attach directly to the hidden post, so I have to go up one level. ---- > 2. What's with /* */ ? Doesn't js allow keyword arguments? It does since version 6. Example: The function call anim_interpolated(ease, name, val, time) should be rewritten thus: anim_interpolated({ease, name, val, time}) The corresponding function definition should be rewritten thus: function anim_interpolated({ease, name, val, time}) { … }