[Idle-dev] Forward progress with full backward compatibility

Peter Funk pf@artcom-gmbh.de
Mon, 10 Apr 2000 09:17:19 +0200 (MEST)


Hi!

Bruce Sherwood:
> Dave Scherer and I have talked quite a bit about possible ways to introduce
> a changed rule for division, so that 1/2 would be 0.5 rather than 0. This is
[...]
> More generally, it would seem useful to have a mechanism for
> incremental yet politically acceptable improvements to Python, with full
> backward compatibility. 
[...]

I appreciate your insightful description about TUTOR.

The discussion of 'pragmas' telling the Python interpreter something about 
a particular source file came up on the 'python-dev' mailing list recently.  
The idea to define a special comment like for example:
    ##Python-Level=1   or 	##Python-Level=2
sure has its merits.  But this idea leaves two fundamental problems open:

1: In the case of changing the meaning of the '/' division operator,
   it is impossible to automatically fix source files, which depend on 
   the old semantic into the new semantic.  Example:
   	42 / some_module.some_function() 
   In Python 1.X the meaning of the '/'-operator is determined by the
   type of the object returned from 'some_module.some_function()' at run-time.
   Assume for example 'some_function' is defined as follows:

   	def some_function():
	    if int(time.time() / 3600) % 2:
	        return 123  # an integer object
	    else:
	        return 123.0 # an float object

   You see what I mean: It is impossible to change the expression above 
   to the proposed language level 2 (aka as Py3k) automatically, since you
   would either have to use use the truncating integer division or
   the floating point division depending on the time of day.

2. What should the new Interpreter do, if he sees a source file without a
   pragma defining the language level?  There are two possibilities: 

   1. Assume, it is an old source file and apply Language level 1 to it.
      This has the disadvantage, that the pragma is required for all new
      source files.  No great problem as long as all programmers new to
      the language would use an IDE and templates.  Unfortuantely you
      can't all those familar with *emacs or *vi* to abbandon their
      preffered editor.  This is an "reliogous" issue. [BTW: This is the
      main reason, why I don't use IDLE yet, although I certainly like
      some of its features]

   2. Assume, it is a new source file and apply language level 2 to it.
      This has the disadvantage, that it will break any existing code.

Regards, Peter
BTW: This discussion is swway off-topic for IDLE.  May be you should reply 
to python-dev@python.org wwith the subject marked with 'Py3k'.  May be you
should review the discussions about 1/2 == 0.5 in the archives.  There are
a lot. :-(
-- 
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen)