Staload dats files

Maybe this question has been asked before. If so, a link to former question
is highly appreciated. Thanks ahead of time.

When we use template feature in ATS, we would usually use staload _ = "xxx.dats" to load the template definition into the current file. Let’s
assume the following situation.

File a1.sats and a1.dats contain template code for certain
functionality. File a2.sats and a2.dats contain template code for other
functionality. File b.sats and b.dats contain template code, which uses
the templates defined in a1 and a2. The main file c.dats uses the
templates defined in b.

Apparently, b.dats must contain
staload "a1.sats"
staload "a2.sats"
Q1. Is it true that if b.dats contains only function templates, then
there is no need to do staload _ = "a1.dats" or staload _ = "a2.dats" inb.datsat all? Q2. Going still further, do we need to use patscc and gcc to compileb.satsandb.dats` and link the results into the final executable?

It seems that c.dats must contain the following
staload _ = "b.dats"
staload _ = "a1.dats"
staload _ = "a2.dats"
Otherwise, we would see errors when compiling the C file generated from
c.dats. (Type checking c.dats has no problem.)

Q3. Is it true that we need to go through the chain of dependency and
staload all the related dats file in c.dats?
Q4. If those function templates in b.dats which are used in c.dats only
depend on those function templates defined in a1.dats, is it true that we
can omit staload _ = a2.dats in c.dats?

There is a basic rule you can follow to understand all of this:

Say you want compile a file foo.dats into object code. Then all the
templates needed in foo.dats, either directly or indirectly, should be
made accessible to the compiler (patsopt).

Answer to Q1:

There is no need
for ‘statload _ = ???.dats’ because you never compile b.dats.

Answer to Q2:
No, you do not (unless you define exception constructors in b.sats or
b.dats).

Answer to Q3: yes, you need

Answer to Q4:
Yes, you can omit.
Including files that are not needed is harmless; trying to get “exact”
sets of file you need is not very meaningful in practice.On Sunday, March 20, 2016 at 2:08:22 PM UTC-4, Zhiqiang Ren wrote:

Maybe this question has been asked before. If so, a link to former
question is highly appreciated. Thanks ahead of time.

When we use template feature in ATS, we would usually use staload _ = "xxx.dats" to load the template definition into the current file. Let’s
assume the following situation.

File a1.sats and a1.dats contain template code for certain
functionality. File a2.sats and a2.dats contain template code for other
functionality. File b.sats and b.dats contain template code, which uses
the templates defined in a1 and a2. The main file c.dats uses the
templates defined in b.

Apparently, b.dats must contain
staload “a1.sats”
staload “a2.sats”
Q1. Is it true that if b.dats contains only function templates, then
there is no need to do staload _ = "a1.dats" or staload _ = "a2.dats" in b.datsat all? Q2. Going still further, do we need to use patscc and gcc to compile b.satsandb.dats` and link the results into the final executable?

It seems that c.dats must contain the following
staload _ = “b.dats”
staload _ = “a1.dats”
staload _ = “a2.dats”
Otherwise, we would see errors when compiling the C file generated from
c.dats. (Type checking c.dats has no problem.)

Q3. Is it true that we need to go through the chain of dependency and
staload all the related dats file in c.dats?
Q4. If those function templates in b.dats which are used in c.dats
only depend on those function templates defined in a1.dats, is it true
that we can omit staload _ = a2.dats in c.dats?