Sambar Server Documentation
|
Differences between C and CScript
|
CScript is a subset of the C Programming language;
while every attempt was made to stay true to the C language,
several simplifications have been made to ease the development of ASP pages.
Syntax
- A main() function block is not required. If none is found,
execution begins at the first statement found in the file.
- Variable declarations are optional and are allowed any place where
a statement is allowed.
- Types are optional and are auto-mangled as necessary.
Explicit type conversion can be performed by typcasting,
i.e.
b = 1; a = (string)b;
That said, when calling functions, the types of arguments must be
specified and are validated at runtime,
i.e. foo (int a, char *b)
- The unsigned modifier is not supported.
- The static modifier is not supported.
- The const modifier is not supported.
- Macros are not supported.
- GOTO statements are not supported.
- Structures, unions, enums and macros are not supported.
Operators
- The operators +, <, <=, >,
>=, ==, != can be used on strings.
- The operator [] performs automatic range checking.
- The sizeof operator returns the number of elements in an array,
the size of a string or the number of bytes used by the
atomic value.
- There is a typeof operator to get the type ID of an object.
- Pointer arithmetic is not supported.
Variables
- Local variables are always scoped to the function block.
Variables used inside compound statements are available in their
outer scope.
- All variables are implicitly initialized to a zero-line value.
- Arrays auto-grow and can have arbitray 'types' as elements.
Array bounds checking is always performed.
- Object references are opaque and only used when passing data
to/from an external API.
Structure
- Case switching is dynamic (can contain expressions).
- Header files are not supported. All libraries are pre-installed
in the execution environment, so STDLIB calls can always be
called directly. User-defined libraries of functions must be
explicity included in the program,
i.e.
#include <foo.c>
© 2001 Sambar Technologies.
All rights reserved. Terms of Use.