# What is the use of staload?

**URL:** <https://discourse.ats-lang.org/t/what-is-the-use-of-staload/240>\
**Category:** Google Group\
**Created:** [November 21, 2013, 9:44pm UTC](https://discourse.ats-lang.org/t/what-is-the-use-of-staload/240 "2013-11-21T21:44:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [November 21, 2013, 9:44pm UTC](https://discourse.ats-lang.org/t/what-is-the-use-of-staload/240/1 "2013-11-21T21:44:07Z")

</div>

Note that staload in ATS is a bit like #include in C. However,  
staload and #include are implemented totally differently.

By staloading a file ‘foo.sats’ as follows, a namespace is created  
for ‘foo.sats’:

staload FOO = 'foo.sats"

A name xyz declared in ‘foo.sats’ should be referred to as $FOO.xyz.

If we next do:

staload FOO2 = “foo.sats”

then there is no actual loading except FOO2 becomes an alias of FOO.

We can also do

staload “foo.sats”

which opens up the namespace for ‘foo.sats’ so that names declared  
in ‘foo.sats’ can be referred to directly.

There is also support for #include in ATS, which simply pastes any  
file to be included at the point where #include is located.

Another use of staload is to make template implementations available to  
the ATS compiler. For instance, the following line makes the template  
implementations in foo.dats available for the purpose of code generation  
(from ATS source to C target):

staload \_ = “foo.dats”

The use of ‘\_’ is to make sure that nothing declared in ‘foo.dats’ gets  
spilled  
out accidentally.
