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?