spacer
Yehuda Shiran June 17, 2000
Compilation Units and Pragmas
Tips: June 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source
WMLScript is a compiled language and uses Compilation Units and Pragmas. A certain application may include separate scripts that were individually and independently compiled. A compilation unit can call functions that are defined in another compilation unit. WMLScript uses pragmas to identify other compilation units that it uses.

The use url pragma specifies the location (URL) of the external WMLScript resource and gives it a local name. This name can then be used inside a function declarations to make external function calls. Let's examine the following example:

use url DocJS "http://www.docjavascript.com/mylibs/mywmlscript"

function divide(nom, denom) {
  if (denominator == 0) return invalid;
  return DocJS#mydiv(nom, denom);
}

The sequence of operations that take place here is fairly intuitive. The use url pragma specifies a URL to a WMLScript compilation unit, http://www.docjavascript.com/mylibs/mywmlscript. If the file extension is omitted (as above), the user agent will look for the extension .wmlsc, i.e. it will look for http://www.docjavascript.com/mylibs/mywmlscript.wmlsc. As we explained in Column 61Introducing WML and WMLScript, WMLScript scripts are stored under .wmls file extension and their compilation results are stored under .wmlsc.

Once the file is found, the function call DocJS#mydiv() triggers the loading of the external compilation unit, http://www.docjavascript.com/mylibs/mywmlscript.wmlsc. Upon successful loading of the external resource, its content is verified to have the definition of the mydiv() function, and it is actually executed with the calling parameters, mydiv(nom, denom). The use url pragma has its own name space for local names, but they must be unique within the same compilation unit.

For more on WMLScript, go to WMLScript Primer.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script · Book Review: Content Rich
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags