Version française
Home     About     Download     Resources     Contact us    
Browse thread
Viper- Dec 1999 progress report
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@m...>
Subject: Viper- Dec 1999 progress report
posted to caml-list@inria.fr and comp.lang.python

Viper - an python interpreter/compiler project written
in ocaml and C, for python and ocaml enthusiasts, 
and those concerned with high performance computing with python.
---------------------------------------------------------------

Here's a brief progress report on the Viper project.

Viper 2.0 alpha 1 is (temporarily) available from

	ftp://ftp.cs.usyd.edu.au/jskaller/viper_2_0_a1.tar.gz

I don't recommend you download this version unless you are
serious about contributing or testing, or just extremely curious. :-)

Ocaml (http://caml.inria.fr), CPython (http://www.python.org) 
and Un*x is required to build it (use the 'maker' script).

The current (temporary) licence permits redistribution of the
unmodified tarball; you can also modify the sources, distribute
the mods as patches, but NOT redistribute modified sources
as a whole (this is to stop some big well funded corporation
cashing in on my work without negotiation)

----------------------------------------------------------
Verion 2.0 alpha 2 features. Note: alpha 2 is NOT yet available.
Too much code is 'unfinished'. Let me know which bits you'd
like to see finished first. A list of alpha 1 features is given
below.

COMPILER and CPYTHON run time access.
=====================================

Alpha 2 now links against the CPython run time, it is possible
to run CPython from within Viper, including loading CPython
extension modules, and letting CPython run scripts instead of Viper.
There is proof of principle support for both converting
between Viper and CPython representations, and wrapping
them as opaque objects (in both directions).

I'm working on a C code generator function that takes a Viper imported
module, and creates a text file which can be compiled with a
C compiler, then loaded into CPython as an extension module.

OPTIONAL TYPE DECLARATIONS
==========================

Viper now supports type declarations in two ways:
The expression:

	expr ! typeexpr

is evaluated as expr if the type of expr is typeexpr,
otherwise a TypeError exception is raised.
Function parameters may be declared like:

	def f(param:typeexpr)

and matching arguments are checked at the point of call.
[Adapted from a suggestion of Greg Stein]

WITH/DO STATEMENT
==================

New syntax is introduced. The With/Do statement is
written like:

	with:
		x = 1
		y = 2
	do:
		z = x + y

The with block is evaluated, and new symbols (x,y) created
in a temporary dictionary. Then the do block is executed,
with the temporary dictionary available read only, write-bypass,
so that z ends up in the global scope. Finally, the temporary
dictionary is deleted. The code above is equivalent to

	x = 1
	y = 2
	z = x + y
	del x,y

except that there is no risk of a clash for the temporary
names, and you don't have to remember to 'del' them.
[Adapted from ML's let .. in construction]

RENAMING EXTENSION IN IMPORT STATEMENTS
========================================

Import statements now allow a suffix to import an object
with a new name. For example:

	import x as y
	from m import a as b, d as e


This saves having to write code like

	_x = x
	from m import x
	new_x = x
	x = _x
	del x

to resolve name clashes.

C STYLE ASSIGNMENT OPERATORS AS STATEMENTS
==========================================

All the C assignment operators (+= etc) plus
pre and post increment and decrement are available
in single assignment statements for example:

	x++
	x+=1

Note that these cannot be used in expressions
or multiple assignments.

NESTABLE C STYLE COMMENTS
=========================

C style /* comments */ can be used an nested.


INTERNATIONAL CHARACTERS IN IDENTIFIERS
=======================================

Any letter can be used in an identifier.
The only encoding supported is UTF-8 encoded ISO-10646.
In particular, Latin-1 encoded non-Ascii characters
will be rejected. The full set of letters allowed is
detailed in: ISO Standard C++, Appendix E.
The source for that was: ISO/IEC PDTR 10176, produced by
ISO/IEC JTC1/SC22/WG20 (internationalisation).
AFAIK, this set agrees with Unicode. All the supported
letters are from the Basic Multilingual Plane (Unicode).

RAW OBJECTS
===========

New raw objects can be constructed, and any object
set as the type object. A demo of showing how to
construct a checked list-of-int is provided.
It remains to be seen if this is enough to
provide generic containers.


BUILTIN GRAPHICS USER INTERFACE
===============================

Viper provides a builtin GUI, currently using Gtk
as the basic C toolkit. Most widget constructors
are implemented (but only a few of the other methods).

LIBRARY MODULES
===============

Most of the socket module is now implemented.
The thread module is implemented. The interpreter,
however, is not yet thread safe. 
Yet to do: operator, array, NumPy, and some others,
finish other partially implemented modules including re. 
Finish implementing mapping/dictionary methods. 
Finish providing support for special class methods. 
Good news: ocaml 3.00 will probably support finalisers, 
so __del__ methods can be made to work.


ALPHA 1 FEATURES
================

Underscores in numeric literals like 1_223_444.
Sane radices for numeric literals: 

	0x - hex
	0o - octal
	0d - decimal
	0b - binary

Full ISO-10646 support for string literals, using 
UTF-8 encoding, and \u and \U escapes.

Builtin support for arbitrary precision rational numbers.

Strides in slices are fully implemented.

Name binding is available for functions and modules.
(names are translated to indexes into an array like
CPython does for locals in functions)

Functions and classes are lexically scoped. For example:

	def f (x):
		def g(y): return x + y
		return g(1)

	print f(2)

will print 3.

Any object can act as a type object in Viper,
type objects are consulted for attributes if
normal attribute lookup fails (including methods).

-- 
John Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850