t.rotate (a, v); // Original
t rotate (a, v); // Who needs dot?
t rotate a, v; // Who needs brackets?
t rotate by: a around: v; // Who needs ambiguity?
t rotateBy: a around: v // This is Smalltalk
t.rotate (a, v); // Original
t rotate (a, v); // Who needs dot?
t rotate a, v; // Who needs brackets?
t rotate by: a around: v; // Who needs ambiguity?
t rotateBy: a around: v // This is Smalltalk
Also, you missed a step. Before "ambiguity":
t rotate by a around v; //Who needs commas? t.rotate(a, v);
...
t rotateBy: a around: v
I will consider only first and last as the rest is just fluffing around.Objectively speaking (yeah right) there is no difference and both serve the same purpose. For whatever reason the first form is more visually and mentally pleasing to me.
If it was written by me it would be:
t.rotate(angle, around);
would also have something more meaningful instead of t unless the scope is very small.And yes, they probably could be used for other purposes. The names are mnemonics for "angle" (a) and "vector" (v). How you arrive at them and what you'd use them for could easily vary across a system.
t.rotate(around, rotateBy)
and the error in the effect might seem very mysterious indeed. The beauty of keyword args is that the mapping of caller's name to function argument name is explicit, and therefore reads correctly or incorrectly immediately at the callsite t rotateBy: point around:degrees
is obviously an error, without sending the reader to look up the definition.Compiler-enforced clarity rather than relying on every individual piece of client code to always name things well & never make a mistake.
I’ve never seen Smalltalk before, but I did find the verbose syntax of ObjC had some benefits.
That being said, typical C programmers don’t add all that whitespace, so the “who needs dots” and stuff is a bit misleading.
t.rotate(a, v).translate(x, y).scale(w, h);
A better way to remove all the "who needs X" is s-expressions. At least then you are left with something that composes a little bit.
t.rotate a v
Alternatively if the rotate method uses named args:
t.rotate --by=a --around=v
(See toitlang.org).