»»»Home «««
Framework
Screenshots
FAQ
»»»TELL «««
Types
Operators
Functions
Example
»»»Toped «««
Database
Cells
Add
Select
Edit
Properties
Rendering
GUI
Miscellaneous
»»»Ifaces «««
GDSII
OASIS
CIF
DRC

Functions

Functions are the basic building blocks of TELL code. Syntactically they look like C code. Below is the list of the main properties of TELL functions

  • Functions can be prototyped
  • There is no main functions as in C. Instead code is allowed outside function boundaries as described in the introduction
  • Functions can be overloaded as long as their type remains fixed.
  • Functions accept arguments and return a value. void keyword is predefined to allow a definition of the function that does not return anything.
  • Functions can be called recursively.

The example below demonstrate the function definition and function call.

   box MOStran(point bound, real W, real L) {
      // draw some shapes
      return {{0,0},{10,8}}; // overlapping box
   }

   void Invertor(point bound, real NW, real NL, real PW, real PL) {
      MOStran(bound,NW,NL);
      // doing something
      box ptrActive = MOStran(bound,PW,PL);
   }

The examples of overloaded functions are Toped build-in functions like addbox, addpoly etc. described later in this manual.

[Warning]Warning

Some overloaded definitions may be ambiguous. If a function is called with anonymous arguments, and more than one of the definitions match the argument list, the result of the call is undefined. Here is an example:

   struct same_as_point {real a; real b};

   function ambi (point A) {
      echo("Input argument of type point);
      // do something
   }

   function ambi (same_as_point A) {
      echo("Input argument of type same_as_point);
      // do something
   }

   point P = {1,1};
   ambi({1,1}); // ambiguous call, any of the overloaded functions
                // can be called
   ambi(P);     // OK, because P is of a known type

The parser is not flagging this type of errors yet.

Recursive function call

Here is a quick example of a function calling itself

int factoriel(real stop)
{
   if (stop > 0)
   {
      int inter = factoriel(stop - 1);
      return (stop * inter);
   };
   return 1;
}

top

Library functions

TELL itself defines predominantly general purpose functions. Toped in turn internally defines and implements a list of functions ensuring its own functionality. In general the editor that interprets TELL shall define and implement its own internal functions. These functions will be parsed first as a part of the initialization phase of the interpreter, so that any internal commands (function calls) received from the command line (or file) can be properly handled.

TELL functions described below are using directly the underlying C functions and more detailed description can be obtained directly from the C math library documentation. One of the few differences is that the trigonometric functions work with angle degrees instead of radians.

Algebraic functions

function Description
real abs ( real X ) Returns the absolute value of the argument.
int ceil ( real X ) Returns the smallest integer not less than the argument
int floor ( real X ) Returns the largest integer not greater than the argument
int round ( real X ) Returns the nearest integer to the argument.
real sqrt ( real X ) Returns the non-negative square root of the argument
real fmod ( real X, real Y ) Returns the floating-point remainder of dividing X by Y
real pow ( real X, real Y ) Returns the value of X raised to the power of Y.

top

Trigonometric functions

function Description
real sin ( real X ) Returns the sine of the argument X where X is given in degrees
real cos ( real X ) Returns the cosine of the argument X where X is given in degrees
real tan ( real X ) Returns the tangent of the argument X where X is given in degrees
real asin ( real Y ) Returns the inverse sine; that is the value whose sine is Y. Result is in degrees
real acos ( real Y ) Returns the inverse cosine; that is the value whose cosine is Y. Result is in degrees
real atan ( real Y ) Returns the inverse tangent; that is the value whose tangent is Y. Result is in degrees

Example 1. Trigonometric functions

   point list arc(point center, int radius, int start, int stop, int numsteps)
   {
      real step = abs(stop -start) / numsteps;
      real current = start;
      point list the_arc;
      while (current <= stop)
      {
         point cur_point;
         cur_point.x = center.x + radius * cos(current);
         cur_point.y = center.y + radius * sin(current);
         current = current + step;
         the_arc[:+] = cur_point;
      }
      return the_arc;
   }

top

Logarithmic functions

function Description
real exp ( real X ) Returns the value of e (the base of natural logarithms) raised to the power of X
real log ( real X ) Returns the natural logarithm of X
real log10 ( real X ) Returns the base 10 logarithm of X.

top

Hyperbolic functions

function Description
real sinh ( real X ) Return the hyperbolic sine of X
real cosh ( real X ) Return the hyperbolic cosine of X
real tanh ( real X ) Return the hyperbolic tangent of X
real asinh( real Y ) Return the inverse hyperbolic sine; that is the value whose hyperbolic sine is Y.
real acosh( real Y ) Return the inverse hyperbolic cosine; that is the value whose hyperbolic cosine is Y.
real atanh( real Y ) Return the inverse hyperbolic tangent; that is the value whose hyperbolic tangent is Y.

top

length

Returns the list length. Empty lists are valid and their length will be 0

[Tip]int length( llst )
<any> list llst
input list

Example 2. length

   int list b;
   echo(length(b));

top

echo

Prints the value of a TELL variable. This function is rather temporary. It takes any type of argument and prints its value in the log window. It could be useful for some very basic debugging of the TELL script.

[Tip]void echo( variable )
<any_type> variable
A variable of any valid TELL type.

Example 3. echo

   echo("Welcome");
   point list triangle{{0,0},{1,2},{3,4}};
   echo (triangle);

top