From cjenkins@tec-usa.com Mon May 8 15:22:05 2000 From: cjenkins@tec-usa.com (Charles E Jenkins) Date: Mon, 08 May 2000 10:22:05 -0400 Subject: [Compiler-sig] Type checking Message-ID: <3916CD8D.6FFA3D2D@tec-usa.com> Hello to all. I hope this is the correct forum for asking about the whys and wherefores of Python compilation. I, too, am interested in seeing strong type-checking added to the language. I wonder what technical reasons prevent strong runtime type-checking from being added. Here's how naive I am. I would think it would be as easy as def myFunc1( num is IntType ) def myFunc2( any_list is ListType ) def myFunc3( string_list is ListType of StringType ) To have superior type-checking, you'd need some way to define type-safe constants: tconst AccessMode is IntType NONE = 0 GUEST = 1 USER = 2 ADMIN = 3 def setMode( mode is AccessMode ): if mode != AccessMode.NONE: blah blah blah In the example above, calling setMode( 1 ) would result in an exception; you'd be forced to use setMode( AccessMode.NONE ) And, of course, functions can still accept an argument of any type if the 'is' clause is omitted. I call myself naive because this is so easy that there must be a very good reason why Python doesn't have these facilities! -- _________________ -- Charles E Jenkins -- MailTo:cjenkins@tec-usa.com From guido@python.org Mon May 8 15:44:15 2000 From: guido@python.org (Guido van Rossum) Date: Mon, 08 May 2000 10:44:15 -0400 Subject: [Compiler-sig] Type checking In-Reply-To: Your message of "Mon, 08 May 2000 10:22:05 EDT." <3916CD8D.6FFA3D2D@tec-usa.com> References: <3916CD8D.6FFA3D2D@tec-usa.com> Message-ID: <200005081444.KAA20695@eric.cnri.reston.va.us> > Hello to all. I hope this is the correct forum for asking about the whys and > wherefores of Python compilation. > > I, too, am interested in seeing strong type-checking added to the language. I > wonder what technical reasons prevent strong runtime type-checking from being > added. > > Here's how naive I am. I would think it would be as easy as [proposal removed] Actually, the correct mailing list for this is the types-sig; the compiler-sig is devoted to issues of parsing and compiling Python, not to language redesign. Adding static optional typing has been discussed at length in the types-sig; in the archives you will find complete proposals (somewhat similar to yours) as well as the reason why this is seen as one of the most difficult changes to Python ever considered. Definitely Python 3000 material! --Guido van Rossum (home page: http://www.python.org/~guido/) From skaller@maxtal.com.au Tue May 9 06:37:11 2000 From: skaller@maxtal.com.au (John Max Skaller) Date: Tue, 09 May 2000 15:37:11 +1000 Subject: [Compiler-sig] Type checking References: <3916CD8D.6FFA3D2D@tec-usa.com> Message-ID: <3917A407.AB98F046@maxtal.com.au> Charles E Jenkins wrote: > > Hello to all. I hope this is the correct forum for asking about the whys and > wherefores of Python compilation. > > I, too, am interested in seeing strong type-checking added to the language. I > wonder what technical reasons prevent strong runtime type-checking from being > added. > > Here's how naive I am. I would think it would be as easy as > > def myFunc1( num is IntType ) > def myFunc2( any_list is ListType ) > def myFunc3( string_list is ListType of StringType ) > Vyper implements this right now. The syntax is to use operator ! rather than 'is': def myFunc1 ( num ! IntType): ... You can also check expressions: x = value ! IntType # raises TypeError if value isn't an int > I call myself naive because this is so easy that there must be a very good > reason why Python doesn't have these facilities! Politics. I implemented the above operator, whose design is attributed to Greg Stein in a couple of days. -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net From etoffi@bigfoot.com Fri May 26 21:27:55 2000 From: etoffi@bigfoot.com (etoffi) Date: Fri, 26 May 2000 16:27:55 -0400 Subject: [Compiler-sig] hello Message-ID: <392EDE4B.BFA223AA@softhome.net> hello