Perl is worse!

Moshe Zadka moshez at math.huji.ac.il
Fri Jul 28 02:19:03 EDT 2000


On Thu, 27 Jul 2000, Steve Lamb wrote:

> On 27 Jul 2000 17:56:55 GMT, Martijn Faassen <m.faassen at vet.uu.nl> wrote:
> >Hmm. You seem to expect that strings and other things will be automatically
> >coerced to integers whenever a function expects an integer. I think that's
> >pretty scary; when I pass in the wrong thing to a function I *want* it to
> >complain, as it's very likely I did it by accident. 
> 
>     The problem there is you're thinking in terms of separate data types.  I
> prefer the freedom of thinking in /DATA/.  Not types, just data.  1.  Is that
> a string?  Is it an integer?  Is it a floating point number?  Yes, it is all
> three.

Huh? Is "ab" an integer? What happens when I do "ab"+1? 1+"ab"?
What happens when I do 1+(6.0**100000)-(6.0^100000)?

Granted, Python makes some differences it shouldn't (longs vs. integers,
for one), but on the whole it has a much saner numeric model then Perl.
Dats *is* typed -- otherwise you can't tell the difference between
"-1" and -1 (one is a flag, the other the unique number x s.t. x+1 = 0)

>     What, strict checking versus TMTOWTDI?  If we're going to have the strict
> checking why, then, don't we have typing up front instead of the half-typing
> we have now?

Huh? Python has *extremely strong typing*. It's just that *values* are
typed, not *variables*

>  Python gets the initial type from context but won't switch types
> based on context?  Might as well force people back into declaring variables in
> certain types since that is implicitly what we have now.

It most certainly isn't.

def foo(a):
	print a[0]

foo("aaaa")
foo([1,2,3])
foo((1,2,3))
foo({0: 'hello'})
t = UserList.UserList()
t.append("hello")
foo(t)

etc.
 
>     Nope.  You stuff a number into a scaler it is a number but can be used as
> a string.  Not that hard to remember.

What about "1a"? "aa"? "1.0"? "1L.0"? "1l.0"? "2-3"?
(I don't care what Perl does -- but those are all things you need to
specify and remember)

> What "type" that data is is completely
> subjective and based on the context of the operation.

Note that this attitude is hopeless in the face of OO: in OO, the *data*
decides on the operation, and should have enough information to do so.
That is called the "type".

--
Moshe Zadka <moshez at math.huji.ac.il>
There is no IGLU cabal.
http://advogato.org/person/moshez





More information about the Python-list mailing list