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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business