<resource>
The <resource> form may be used to define resources that exist in a
unique namespace and are global to the session. (Available as of version
12.20)
Description
The <resource>, which must appear within <library>,
consists of definitions relevant for a particular language. Once a resource has been defined
by importing or submitting the library containing <resource>, it may not
be given a new definition without first clearing the cache. If you attempt to redefine a
function, the code will throw an error. However, you may define a resource multiple times
with the same definition, meaning that you can import libraries containing
<resource> multiple times without throwing an error.
Variables defined within a resource may be referred to by the syntax
@.[RESOURCE_NAME].[VARIABLE_NAME]
even outside the resource.
Syntax
<library>
<resource name="[NAME_OF_RESOURCE]" for="[LANGUAGE]"
[CONTENTS_OF_RESOURCE]
</resource>
</library>
Attributes
name- The name of the resource you are defining.
for- The language for which the resource is intended.
Valid values are:
Example
In this example, a simple function called "myu" is defined based on a K resource. The
function is defined in K within the <resource> tag. The namespaces
defined here are available everywhere <code language_="k3"> blocks are
used: in the opstream, in <def_ufun> and <def_gfun>,
in <do>, <tabu>, <sel>,
<willbe>, and so on.
<resource name="myu" for="k3"> myfavoritenumber:17.0 add:{x+myfavoritenumber} </resource> <def_ufun name="addnum" args="x" types="f(i,f)" code=".myu.add[x]" in="k3"/>
