Chapter 7. Scilab Core

Table of Contents
Introduction To pAda
Internal Data Structure
Writing Native Scilab Functions
Error Handling
Interface to Scilab's Core

Good morning Mister Tyler! Going down?

-- Aerosmith video "Love In An Elevator", "Pump" (1989).  

We are going down all the way right to the core, the core of Scilab. Though this is the most technical and most complex chapter, it is by no means true that writing a native Scilab function is unmanageable by for ordinary mortals. A strict programming discipline, patience, persistence, and a thorough knowledge of what makes up the stack-structures involved, let us overcome the difficulties.

Introduction To pAda

Instead of simply repeating the Fortran-77 statements that make up the Scilab stack, the API, etc., we introduce a new language that is better suited for this job: a pseudo Ada[1] (pAda), which is much more expressive. The syntax follows Ada, and the pAda types are mapped onto Fortran-77 types as listed in Table 7-1. What might look like an artificial complication, the introduction of new types, actually is a major simplification. First, the name of the type now makes clear exactly what it is used for. Second, distinct types designate distinct things, stuff that never should be mixed up. Third, the valid ranges of the sub-types are explicity mentioned.

Table 7-1. pAda to Fortran-77 type mappings

type String is array (1..N) of Character CHARACTER*N
type ComplexFlag is (RealVariable, ComplexVariable) INTEGER = 0, 1
subtype Natural is Integer range 0..Integer'Last INTEGER
type ParameterStackAddress is new Integer range 1..Integer'Last INTEGER
type DataStackIndex is new Integer range 1..Integer'Last INTEGER



We apologize to all Ada programmers for the abuse of the language, but Ada's expressiveness and clarity are unmatched.