On 01/11/2011 02:22 PM, Steven Schveighoffer wrote:
A tree is a kind of set, so instead of "insert()" I'd like a name like
"add()".
(But maybe this is not standard in D).
The function names must be consistent across containers, because the
point is that complexity and semantic requirements are attached to the
function name. The function names were decided long ago by Andrei, and
I don't think insert is a bad name (I believe std::set and std::map in
C++ STL uses insert).
I have thought at this naming issue, precisely, for a while.
"add" is bad because of connotation with "addition". D does not use '+'
as operator for putting new elements in a container: this is a very
sensible choice imo.
"insert" is bad because of "in-between" connotation: does not fit when
putting an element at the end of a seq, even less for unordered containers.
"put" instead seems to me the right term, obvious and general enough:
one puts a new element in there. This can nicely adapt to very diverse
container types such as sequences including stacks (no explicite index
--> put at end), sets/AAs, trees,...
Denis
_________________
vita es estrany
spir.wikidot.com