Smart Pascal is an Object Pascal programming language that is derived from Delphi Web Script and is adapted for Smart Mobile Studio for generating commercial JavaScript machine code. As a rapid application development (RAD) language, it contains a library of classes and components. The Smart Pascal compiler is a source-to-source compiler generating server-independent applications which are compliant with HTML5. Compiled Smart applications can be executed in a modern HTML5-capable browser. A compiled program is then typically embedded within a DIV container element or alternatively set to occupy the entire display.

History

edit

Smart Mobile Studio, designed by Jon Lennart Aasenden and Eric Grange, is published by software company Optimale Systemer. It uses Delphi Web Script, an open-source scripting engine, for syntax verification and parsing. On 18 May 2012, Optimale Systemer disclosed that it had acquired the rights to a custom code generator written by Eric Grange, the maintainer of Delphi Web Script, from his company, Creative IT. Eric Grange introduced anonymous classes in Smart Pascal starting from version 1.0.

Prototype

edit

The first prototype was released on 20 December 2011. The project received full two-page coverage in Blaise Pascal Magazine. The run-time library grew to include support for Remobjects SDK and Embarcadero Datasnap. From version 2.0, Smart Pascal also supported NodeJS, Web Workers and the Espruino microcontroller platform.

Linguistic differences

edit

Property expressions

edit

In Object Pascal, a property is an exposed value that can either be linked to a class-field or a class-member method. The consumer does not know if the property is explicitly linked to a field or a writer method. Smart Pascal introduces a technique called "property expressions". It allows the user to program reader and writer logic as a part of property declarations.

The Smart Pascal IDE built object-oriented, modular applications designed to live in an HTML document. Separate windows can be populated with controls, and code events can be connected to these to respond to user activity. Smart Mobile Studio does come with a visual form designer and property editor. The Smart Pascal run-time library has full support for creating CSS3 styles, "tweening", display redraw synchronization, GPU-powered 2D and 3D sprites and WebGL.

Database access

edit

The engines WebSQL, IndexedDB and WebStorage API are supported.[as of?] The Smart IDE also allows access to Embarcadero DataSnap, which is a remote-data-access framework. Using these import libraries allows Smart Pascal applications to read, write and update remote datasets. Smart Pascal is itself written in Embarcadero Delphi. The run-time library includes classes for RemObjects SDK, a remote procedure call framework along the lines of Microsoft RPC. JSON RPC and WebSockets are likewise part of the class library.

Array operations were added to the Smart Pascal syntax to better adapt to JavaScript. Smart Pascal has a built-in for all arrays, as long as the datatypes match.

Anonymous classes

edit

In traditional Object Pascal, all classes inherit from a root type called TObject. This was also the case for Delphi Web Script. To import JavaScript classes, the dependency on TObject as the root of all class types needed to be modified. This allows the user to define a class as external, and classes written in JavaScript that match the interface can thus be created and used alongside those written in Pascal. Anonymous classes can also be used as lightweight objects.

Limited support

edit

The anonymous method was introduced in Smart Pascal as a means to improve compatibility with JavaScript. Under native Pascal, users have class procedures and ordinary procedures. The only difference between these two is that if the user wants to reference a class method, they must append "of object" to its declaration. The compiler does not allow you to reference an object method without "of object" being clearly defined.

Partial classes are yet a feature that has not made it into the Object Pascal standard. Smart Pascal supports two declaration formats of partial classes. The RemObjects Oxygene Pascal syntax and also the "type mytype = partial class(ancestor type)" variation.

In Pascal, a set is a collection of elements of the same type. The Smart Pascal syntax currently supports only sets of enumerations with the "in" operator and "include(aSet, aValue)" or "exclude(aSet, aValue)" methods. Smart Pascal does not support generics. The original syntax of Delphi Web Script Smart Pascal derives from was compatible with Delphi 7. Run-time type information is inpart supported by DWScript, including the ability to enumerate properties and class members. RTTI is implemented by the Smart Pascal JavaScript compiler if the "Emit RTTI information" is defined in the Project's Compiler options.

Sources

edit

External references

edit