| By Thomas Zang | Article Rating: |
|
| January 5, 2009 09:30 AM EST | Reads: |
3,193 |
At runtime, users can create a multidimensional array as follows:
arr = create int[4, 2 to 5]
which creates a two-dimensional integer array, with indexes of the two dimensions being 1 to 4 and 2 to 5.
Jag-array will be allowed to be declared. For example, int arr[][], which is a integer jag-array.
At runtime, users can create a jag-array as follow:
arr = create int[3][]
arr[1] = create int[5]
arr[2] = create int[20]
arr[3] = create int[10]
The first line creates an array with three elements, each of type int[] . The subsequent lines then initialize the three elements with references to individual array instances of varying lengths.
In .NET, a delegate type represents references to methods with a particular parameter list and return type. Delegates are similar to the concept of function pointers in some languages, such as C, but unlike function pointers, delegates are object-oriented and type-safe. In PB12, users will be able to make use of the .NET delegate type to cooperate with native PowerScript code.
The following example declares and uses a delegate type named Function in an imported .NET assembly.
.NET delegate declaration in C#:
delegate double Function(double x);
Consuming this delegate type in PowerScript:
public function double[] Apply ((double a[], Function f)
double result[]
for i = 0 to i < a.Length step 1
result[i] = f(a[i])
next
return result
end function
public function double Multiply(double x)
return x * factor;
end function
public function test()
double a[] = {1.0,2.0,3.0,4.0,5.0}
double doubles[] = Apply(a, Multiply)
end function
In PB12, the standard NVO will be able to inherit from a .NET class, which will override all virtual and abstract methods, properties, indexers, and events defined in the .NET base class and implemented interfaces.
Table 1 provides an overview of the kinds of members of a .NET class that can be exposed in PB.
This syntax of calling PowerScript functions and events will also be used to call the functions and events of .NET class as follow:
{ objectname.} { type } { calltype } { when } name ( { argumentlist } )
In .NET, generics are classes, structures, interfaces, and methods that have placeholders (type parameters) for one or more of the types that they store or use.
A generic collection class might use a type parameter as a placeholder for the type of objects that it stores; the type parameters appear as the types of its fields and the parameter types of its methods. A generic method might use its type parameter as the type of its return value or as the type of one of its formal parameters. In PB12, users will be able to consume .NET generic classes and methods, if they conform to generic CLS rules. But defining a generic type and overriding a generic method won't be supported.
Here's an example of consuming generic type in PB:
System.Collections.Generic.SortedList<string, integer> teams
teams = create System.Collections.Generic.SortedList<string, integer>
teams["DEV"] = 30
teams["QA"] = 25
In PB12, users will be able to define a global enum type; the new enum painter will be similar to Structure Painter as shown below.
To define a local enum, users will have to open the object painter that has a local enum painter attached.
The following kinds of PB objects will be able to define local enum: Custom Class, Standard Class, Custom Visual, Standard Visual, Window, and Menu.
In PB12, the following kinds of PB objects will be able to specify which namespace the object group belongs to and which namespaces the object group is using: Custom Class, Standard Class, Custom Visual, Standard Visual, Window, Menu, Structure, Function, Interface, and Enum.
There are two ways to identify a unique name. The first one is to use qualified names. That's a namespace name followed by the scope-resolution operator (.) and then the name of either a nested namespace or a group and the name of a member of a group. For example:
MyPkg.MyNestedPkg.w_main`cb_1
The second way is to use a using directive:
Using pkg1[.pkg2[.pkg3]...]
A using directive allows a named type to be referred to by a simple name that consists of a single identifier.
Currently in PB, a default constructor event is used to instantiate object. When a PB NVO object is created at runtime, an auto-generated oncreate event will be triggered in which the default constructor event will be subsequently triggered.
But the default constructor event doesn't support overloading so it will lose its flexibility to instantiate and initialize a particular type of object.
In PB12, parameterized constructor events will be supported, but they will only apply to custom and standard NVO types.
The syntax will be as follows:
objectvariable = create objecttype[(arg1[,arg2]...)]
In .NET, the custom attribute is a class used to represent custom metadata.
In PB12, users will be able to define a custom attribute class, but only some .NET types and their corresponding PB types can be useable as an attribute parameter type.
The syntax will be enhanced to support defining and applying custom attributes as follow:
global type EventPrototype from System.Attribute usage [event]
end type
type variables
public string prototype
end variables
forward prototypes
subroutine EventPrototype(string prototype)
end prototypes
subroutine EventPrototype(string pt)
prototype = pt
end subroutine
[EventPrototype("pbm_lbndblclk")]
event clicked
end event
Published January 5, 2009 Reads 3,193
Copyright © 2009 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Thomas Zang
Thomas Zang is a staff software engineer at Sybase. He works in the Singapore kernel team of the PB department and is in charge of the PowerScript language enhancement project in PB12.0.
- Yahoo! to Keynote 4th Cloud Expo: Accelerating Innovation with Cloud Computing
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- Yahoo! SVP Shelton Shugar to Discuss Innovation at Cloud Computing Expo
- Ulitzer Provides a Powerful Social Journalism Platform
- Live Demo of Yahoo! Query Language at Cloud Computing Expo
- Bernanke Should Go Back to Teaching
- How to Extract Your Contacts from LinkedIn and Facebook
- Yahoo! Announces Open-Source Cloud Server
- Google Responds to the Bing Challenge
- Google Open Sources its JavaScript Tools
- Adobe Cans Another 9% of its Workforce
- Unix Co-Creator Writes New Open Source Programming Language for Google
- Yahoo! Named “Platinum Sponsor” of Cloud Computing Expo
- Yahoo! to Keynote 4th Cloud Expo: Accelerating Innovation with Cloud Computing
- Confessions of a Ulitzer Addict
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- Twitter, Linked In, Ning and Ulitzer: Easy Personal Branding Strategy
- Ulitzer Live! New Media Conference & Expo
- Ulitzer vs. Ning
- Yahoo! SVP Shelton Shugar to Discuss Innovation at Cloud Computing Expo
- Google Wave Hits Wider Beta
- Ulitzer Provides a Powerful Social Journalism Platform
- Social Media on Ulitzer - Strategy Nets New AUM for RIA
- Live Demo of Yahoo! Query Language at Cloud Computing Expo
- Where Are RIA Technologies Headed in 2008?
- The Top 250 Players in the Cloud Computing Ecosystem
- Google Version 2.0: Googzilla - The Calculating Predator
- Google Space Launches at Heathrow Airport
- SEO/SEM Tips & Tricks: How and When Should You Submit Your Website to Google?
- Google Snaps Up the Father of the Orion Search Engine
- AOL To Enhance Video Search Engine by Adding RSS Feeds
- Ulitzer vs Knol - Google Wants Its Own Wikipedia
- AJAXWorld Knocks Spots Off LinuxWorld
- The World's Youngest "Google Entrepreneur" Is One Month Old
- Microsoft's Chase After Google Reverberates
- Google Jabbers On with GoogleTalk































