Scoped includes and constants areawesome.
On Tuesday, September 25, 2018 at 3:28:05 PM UTC-4, M88 wrote:
>
> Hello,
>
> I was wondering if it's possible to use a template to define the size of a
> statically allocated array in a template.
>
> An example (that won't compile) is:
>
> exter
Slightly neater. Note that you can have cover (multiple; expressions) with
a single where {}
#include "share/atspre_staload_hats."
implement main0() = example() where {
#define example$bufsz 100
#include "./testarr.hats"
}
On Tuesday, September 25, 2018 at 3:46:17 PM UTC-5, Julian Fondren
I see.
Then there isn't really a way to do this as the 'sz' in @[a?][sz]
is static.
I will keep an eye on it. Maybe I can find a way to support it in ATS3.
On Tuesday, September 25, 2018 at 7:01:48 PM UTC-4, M88 wrote:
>
>
> I get an error during C compilation, ATSERRORarrdim_unknown, when I try
I get an error during C compilation, ATSERRORarrdim_unknown, when I try to
use a template function.
Thanks Julian -- that's a decent solution.
On Tuesday, September 25, 2018 at 3:28:05 PM UTC-4, M88 wrote:
>
> Hello,
>
> I was wondering if it's possible to use a template to define the size of
You can use a function template:
fun {} example$bufsz() : [n:pos] size_t n
Because of inlining, you should get what you wanted in the first place.
On Tue, Sep 25, 2018 at 3:28 PM M88 wrote:
> Hello,
>
> I was wondering if it's possible to use a template to define the size of a
> statically a
An option.
testarr.dats:
#include "share/atspre_staload.hats"
local
#define example$bufsz 100
in
#include "./testarr.hats"
end
implement main0() = example()
testarr.hats:
extern fun {a:t@ype} example(): void
implement {a} example() =
let
val sz = example$bufsz
var buf = @[a?][e
Hello,
I was wondering if it's possible to use a template to define the size of a
statically allocated array in a template.
An example (that won't compile) is:
extern
fun {a:t@ype} example () : void
extern
val {} example$bufsz : [n:pos] size_t n
implement {a}
example () =
let
v