|
||
|
This section is for developers already familiar with SilverC, SilverPlus, or SilverEngine that are interested in taking up SilverSharp.
|
|
||||||
Because C# does not permit global functions or variables, that is public symbols declared outside the boundaries of a class, access to the SilverScreen API is through a sealed, abstract data type named SC. After referencing the SilverSharp assembly in your application, you may use the functions documented in the SilverScreen API by referencing them through the SC class of the SilverSharp namespace. For instance, here is a short piece of code making random calls into the SilverScreen API:
For consistency's sake SDC chose to use the same data type names across development platforms. This means that an OBJECT_NODE in the SilverC platform and an OBJECT_NODE in the SilverSharp platform both represent a SilverScreen object entity. However, an OBJECT_NODE in the SilverC platform is a reference to a c-style unmanaged structure declared in ssnodes.h, and an OBJECT_NODE in the SilverSharp platform is a reference to a managed class declared in the SilverSharp assembly. They are logically consistent, but their implementation is very different. Likewise, the SilverScreen API functions that are part of the SilverSharp platform have parameters and return types that are CLR-compatible, but have preserved their names. Finally, many of the SilverSharp managed classes have been extended to work more naturally in CLR languages. The guiding principal behind SilverSharp was to keep the end-result as familiar as possible to existing developers, but not at the expense of experienced CLR-language users.
There were rare instances when maintaining legacy syntax would hinder or confuse CLR-language users. One such instance involves string formatting as practiced in C# as opposed to as practiced in C.
The ss_command function that is part of the SilverSharp assembly uses the formatting style that is ubiquitous to C#, rather than the style that is practiced in C languages.
For example, in SilverC, SilverPlus, and SilverEngine platforms the following code draws a polygon:
The same code, for the SilverSharp platform, would look like this:
While experienced developers might argue in either direction, that is towards API consistency or towards language consistency, we chose to honor language consistency (for the same reasons that C# designers made the same decision).
|
|
|||||||
|
|
|||||||
|