Op 2005-03-16, Diez B. Roggisch schreef <[EMAIL PROTECTED]>:
>>> Consider this:
>>>     a = (3 + 5) * 5
>>> You really, really want (3 + 5) to be an integer, not a one-item tuple. 
>> 
>> I sometimes do wonder if some impliciteness wouldn't be better here,
>> so that any item could be treated as if it was a one-item tuple.
>> 
>> A bit like every char being a string.
>
> There is no char. There are strings of lenght 1.

That is a matter of view. But to illustrate what I mean,
the following is an infinite loop in python

  s = 'hi'
  while true:
    s = s[0]

> And the above example makes
> it clear that there would be an ambiguity that could _maybe_ be solved in a
> static typed language (the application of the (3+5) as left side to the
> operator <*> if <*> only is defined as [num, num] -> num), but clearly not
> in a dynamic typed one as python.

That ambiguity is only caused because python uses the same characters
for very different operations and to be honest I don't like that.

for instance I have written once somekind of vector class where
it was natural for these vectors to be added as well as te be
concatenated. Unfortunately python uses "+" for both so I had
no way to have both operators in a natural way in python.

So that a <*> would create an ambiguity if items would be silently
transformed in a one-item tuple when appropiate is IMO more caused
by the design decision to use <*> for two totally diffent operations
then because of the dynamic nature of python.

> And if the static typed language allows operator overloading, it could very
> well be that someone creates a overloading for 
>
><*> : [tuple[num], tuple[num]] -> <whatever>
>
> which would reintroduce the ambiguity.
>
> Soooooo, in the end it boils down to some explicitness - where IMHO an
> additional comma is pretty much no problem at all. Another option would of
> course be the introduction of different parentheses for tuples - but I
> can't find some on my keyboard.

Well I can't find braille on my keyboard, but if I wanted to, it
wouldn't be difficult to get it on my screen. So is it with
different parentheses. That python can't use these parentheses
is again a design decision.

-- 
Antoon Pardon
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to