[Types-sig] Syntax

Greg Stein gstein@lyra.org
Sat, 18 Dec 1999 16:04:05 -0800 (PST)


On Sat, 18 Dec 1999, Tony Lownds wrote:
>...
> I think it'd be possible to put type declarations in-line without using a
> new binary, at least in the short term:
> 
> 1. make a module that overloads __import__()
> 
> 2. when a module is imported it asks the syntax handler to parse the file 
> and generate a plain .py file and a .pi (ie "interface") file with
> appropriately nested dicts in it.
> 
> 3. Then it asks the type checker to make sure the .pi and .py match up.
> The type checker may need to call __import__() recursively.
> 
> 4. Then, __import__() should import the generated .py file.

Interesting approach!

However, I'd think that implementing that would be about the same
difficulty as altering Python's grammar (i.e. not a walk in the park, but
not hard). But if a single binary is important (for now), then your
thought is quite valid.

Over the next week or so, I'm going to be work on Python's import system.
Depending on whether Guido likes the changes and if checks them in, then
tweaking the import as you mention would get a good deal easier.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/