3 ms·
So position is like a typedef that you can use without a name, because it is self-naming. Obvious problem: def Drawline(position, position): ... Oops! We
by kazinator 12y ago
So position is like a typedef that you can use without a name, because it is self-naming.
Obvious problem:
def Drawline(position, position): ...
Oops! We now need a position0 brand and a position1 brand, both of which are aliases for Point.
- seanmcdirmid 12y agoThey aren't just type aliases, they actually have unique slots in the symbol table when used so...you define more brands :) brand position <- Point brand start-position <- position brand end-position <- position def DrawLine(start-position, end-position): ... = start-position + ... ... = end-position - ... But that is kind of annoying, brand composition as adjectives would probably work better: brand position <- Point brand start brand end def DrawLine(start&position, end&position): ... = start&position + ... ... = end&position - ... Very natural language, and start/end can be used to qualify all variables that are starty or endy. The biggest problem with the approach is that you have to think ahead of time about what your variables mean, and they might become fairly verbose (so "start position" rather than "startp"). Also, when you get into the implementation, it is kind of tiring to think about what every local variable should mean, so maybe this only really works for procedural parameters and maybe to help define fields. I've been thinking about this for awhile, but haven't put it into a prototype yet.