Whither Tango?

Jonathan M Davis jmdavisProg at gmail.com
Sat Feb 20 18:55:31 PST 2010


Rainer Deyke wrote:

> Andrei Alexandrescu wrote:
>> Rainer Deyke wrote:
>>> Andrei Alexandrescu wrote:
>>>> Anyhow, what's a better name?
> 
> Python calls it 'range':
>>>> range(1, 5)
> range(1, 5)
>>>> list(range(1, 5))
> [1, 2, 3, 4]
>>>>
>>>> list(range(1, 5, 2))
> [1, 3]
> 
> I like 'range'.  It's short, it's descriptive, it's immediately
> recognizable to someone new to the language.
> 
> You could argue that calling this function 'range' would lead to
> confusion between the range concept and the range function.  In that
> case, you could add a verb and call the function 'makeRange'.
> Alternately, if the function is only meant to take numeric arguments,
> then 'numericRange' could help distinguish it from other functions that
> return ranges.  However, I think that 'range' by itself is sufficiently
> clear and unambiguous.
> 
> 

I think that makeRange or range would be _highly_ confusing given how the 
term range is used in D, and personally, I wouldn't find it much clearer 
anyway. And can python's range allow for steps greater than 1 between 
numbers? It's not simply the range of numbers between the first and second 
number given. It's the range of numbers with a given step size between each 
number. So, it's not really a range.

I agree that iota is a rather bizarre name, but I haven't a clue what to 
call it. The function is already complicated enough that it really needs 
examples to figure out what it's doing. I certainly can't think of a name 
which comes close to accurately describing what it's doing. And anything 
with range in the name would just increase the confusion.

I tend to agree with Michel in that it's better to have a name which is not 
immediately obvious but which _is_ memorable. That way, you have to look it 
up and actually understand it. And then you'll remember it. Unless a name 
can be found which makes it crystal clear what it does, I think that it's 
far better to just leave it as iota. And if there are other languages which 
already use iota for a function which does this, then it makes that much 
more sense to stick with the name. Then it _will_ be clear to people who 
have seen it in other languages.

No, iota is not the best name ever, but I think that it should be left as it 
is.

- Jonathan M Davis



More information about the Digitalmars-d mailing list