Typing [Re: total idiot question: +=, .=, etc...]

Joshua Rosen rozzin at geekspace.com
Tue Jun 29 14:57:43 CEST 1999


Reimer Behrends wrote:
>         Require variables to be prefixed with "$" to denote scalar
>         values--strings and integers, "@" for lists, and "%" for
>         dictionaries.
> 
> Given the precedent of having to use self to access instance variables,
> this is entirely consistent with the current language, and is going to
> eliminate all those nasty problems where you can't tell from the context
> what the type of a variable or function is. :)

	+There is no difficulty in getting the program to know what type some piece of
data is, which lessens the need for the type-declaring prefixes--use type(),
and then check obj.__class__ if obj is a class-instance, and you need to -know-
what class it is (if you want to -force- it to be a certain type, keep
reading).
	+Requiring variables to bear a prefix denoting type sortof makes Python into a
statically-typed language, where one of the big reasons for using it is that
it's a dynamically-typed language.
	+There is no such thing as a `scalare', in Python--strings and numbers are
different data-types, numeric data can actually be one of many different
classes.
	+Forcing data to be of a specific type is already possible--see documentation
on int(), str(), list(), tuple(), float(), long(), complex(), string.atoi(), et
al. This functionality also lessens, if not completely eliminates the need for
typing prefixes; the program knows what type the data is being coered into, and
so does the programmer. In fact, all of the functionality that you're proposing
(and then some) is already there--it just looks different.
	+If you really want a feature that -really- isn't offered by a language, the
best decision may be to just use another language that -does- offer it. Try
Pike, for one (I suggest it because it has nifty typing which you may like: you
can declare a variable to be one or -more- types, or use a mixed type). Choose
your languages based upon what you need them to do.


		-Rozzin.





More information about the Python-list mailing list