Bistro - SIF Conversions

Feedback from a few interested parties and due consideration convinced me that it will be advantageous to support roundtrip conversions between Smalltalk Interchange Format (SIF) and Bistro. Primary amongst these are that:

Conversion Basics

Given the syntactic similarities between Smalltalk and Bistro, conversions between SIF and Bistro are easy for most program elements. However, there are several areas which raise mapping issues.

Types

While Bistro and Java support first-class type definitions, Smalltalk has no mechanism for defining types (or interfaces) independent of classes. Conversion conventions could be established from Bistro to Smalltalk using type annotation comments and abstract Smalltalk classes. However, the value of such conventions would be minimal because they would have no practical development usage within the Smalltalk environment. For this reason, roundtrip conversion will not address Bistro types directly. Bistro classes that implement types will carry their types implementation information as comments to support correct reconversion back to Bistro.

Packages

The most mature Smalltalk environments include the ability to catgorize classes and methods (with class categories and method protocols). The SIF specifications reflect this by defining several standard annotations types, including a category annotation. By convention, the conversion utilities (will) use the category annotations to carry Bistro package names.

Primitives

While the ANSI standard for Smalltalk does not discuss primitives, virtually all commercial and open source Smalltalks support the inclusion of primitive declarations at the beginnings of methods, typicially with a form similar to the following:

<primitive: 9999>

System and user primitives are typically implemented in some other programming language, e.g., C or C++. Although, the open source Squeak Smalltalk provides a mechanism for defining primitives in Smalltalk, compiling them to C, and including them in the VM construction process (very cool).

Bistro supports the direct definition of primitive methods using Java, as well as the usage of the Java Native Interface (JNI) for accessing primitive libraries. Here are examples of both kinds of Bistro methods.

"a primitive Bistro method"
protected (Integer) getPentagonalConstant { return primitive.IntegerFrom( 5 ); }
"a native Bistro method"
protected native (void) accessExternalResource []

Because of the substantial difference in primitive models, roundtrip conversions will not address Smalltalk primitives and primitive Bistro methods. Designs that require access to primitives should ensure that the primitive methods are well factored and isolated in object layers (both Smalltalk and Bistro) that are not subjected to roundtrip conversions. The conversion utilities will report errors when they encounter primitive methods.

Pools and Globals

The mechanisms to support Smalltalk pools and globals during roundtrip conversions is under development.


Java™ is a trademark of Sun Microsystems, Inc.

Permission is granted to copy this document provided this copyright statement is retained in all copies.
Copyright 1999-2002 Nikolas S. Boyd.