Differences Between Slick-CŪ and C++

Structures

  • Space for structure member variables is allocated when you access the member.

  • Structure data is not continuous. This is obvious for string, array, and hash table member variables that contain variable size data. However, even other types are sometimes stored elsewhere.

  • There is not a sizeof function that tells you the size of a structure in bytes.

Arrays

  • Space for array elements is allocated when you index into the array.

  • You cannot use pointer variables to traverse array elements.

  • You cannot limit the number of elements that the array may contain.

  • Specifying an array variable without the []operator does not return a pointer to the first element. Instead it refers to the entire array. This allows you to copy one array to another or define a function that returns a copy of an array.

  • There is not a sizeof function that tells you the size of the array in bytes. There is a _length method that tells you the number of elements in the array.

Example:

struct PHONERECORD {
   _str name;
   _str PhoneNumber;
};
 
defmain() 
{
   PHONERECORD list[];  // No size limit is allowed here.
 
   // Allocate space for 0 index and name member.
   list[0].name=Joe;
   // Allocate space for PhoneNumber member.
   list[0].PhoneNumber=555-1234;
 
   PHONERECORD list2[];
   list2=list;   // Copy the entire array into list2.
   t=list2;  // Now copy the entire array into a container variable.
}

Hash Tables

Slick-CŪ provides a :[] hash table operator that is similar to the array operator [] except that hash tables are indexed with a string type or by class objects. See Hash Tables for more information.

Assignment Statement

Assignment statements in Slick-CŪ are not as shallow as C++. Array, hash table, and structure types are recursively traversed. Pointers are not traversed.

Example:

struct {
   int a[];
} s1,s2;
s1.a[0]=1;
s2=s1;  // Copy stucture and all elements of array.

Comparison Operator

The == and != operators support comparing container types, arrays, hash tables, and structures. Complex types are traversed recursively, like the assignment statement. Strings within an array, hash table, or struct must match exactly (spaces matter).

Preprocessing

Preprocessing expressions can use string and floating point expressions.

switch Statement

The switch statement supports string expressions and integer expressions.

Labeled Loops

The break and continue statements accept an optional label parameter so that you can break a specific loop (like Java).

Example:

outerlabel:
       for (;;) {
          for (;;) {
             if () break outerlabel;
             if () continue outerlabel;
          }
       }

Variable Argument Functions

An arg function allows you to define functions that accept a variable number of arguments. The arg function can be used on the left side of an assignment statement.

Example:

 defmain()
   {
      p(Param1,2,x);
   }
   void p()
   {
      messageNwait(Called with arg() arguments);
      for (i=1;i<=arg();++i) {
         messageNwait(arg(i)=arg(i));
      }
      // All undeclared variable parameters are passed by reference so when
      // a variable is passed, we can change the contents of the callers variable.
      arg(3)=New value for x;
   }

Built-in Graphics Primitives

You can define dialog box resources and menu resources. There are primitives for defining event handlers for dialog boxes and declaring control types. This allows the Slick-CŪ linker to detect a reference to a control that does not exist on a dialog box before you execute the code.

Clipboard InheritanceŪ

Clipboard Inheritance provides inheritance specifically for dialog boxes. This feature enables the copying of parts of existing dialog boxes to the clipboard and pasting them elsewhere, and the original code still runs. New code can be attached to the new controls without affecting the original controls, and to affect both instances of the controls (inheritance). Creating inheritance for parts of dialog boxes is very natural because the Slick-CŪ language has been designed for this feature. See Clipboard InheritanceŪ for more information.

End of Statement Semicolon

Slick-CŪ assumes that the end of line is a semicolon except under a few conditions. Expressions may extend across line boundaries if the line ends in a binary operator or if the line ends with a backslash, and expressions in parentheses may extend across line boundaries.

Type Checking

Type checking in Slick-CŪ is identical to C++ except for the following:

  • The typeless type is compatible with ALL other types.

  • String constants are automatically converted to numeric types where necessary.

  • Integer types are automatically converted to string types.

  • Functions do not require prototypes. However, when a prototype is given, strict type checking is enforced like you would expect. A #pragma option to require prototypes will eventually be added.

Capability not Supported by Slick-CŪ

  • You cannot define your own classes, methods, or inheritance. The class, public, private, and new keywords are not supported. Classes in Slick-C will not require a delete to free objects.

  • Only one syntax is currently supported for making a call with a pointer to a function variable. The pfn(p1,p2, ) syntax is not supported. This limitation is necessary for container variables because the compiler does not know the type of the variable.

  • char and short types are not available.

  • Template classes are not supported. Container variables are sometimes a more powerful mechanism for accomplishing much of what is done with template classes. However, container variables lack the speed and additional type checking of template classes.

  • Function overloading is not supported.

  • enum is not supported.

  • Slick-C only supports the less ambiguous C-style type casting.

  • Because Slick-C does not allow low level manipulation of memory, you cannot do things like type cast an int * to a long *.

  • There are no character constants defined using single quote characters. Slick-C currently allows the use of single quotes to define strings. Single quoted strings are much more readable for file names or regular expressions that require the use of backslashes.

  • goto is not supported. (Slick-C supports labeled loops.)