An option.
testarr.dats:
#include "share/atspre_staload.hats"
local
#define example$bufsz 100
in
#include "./testarr.hats"
end
implement main0() = example<int>()
testarr.hats:
extern fun {a:t@ype} example(): void
implement {a} example() =
let
val sz = example$bufsz
var buf = @[a?][example$bufsz]()
in end
On Tuesday, September 25, 2018 at 2:28:05 PM UTC-5, 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:
>
> extern
> fun {a:t@ype} example () : void
>
> extern
> val {} example$bufsz : [n:pos] size_t n
>
> implement {a}
> example () =
> let
> val sz = example$bufsz<>
> var buf = @[a?][sz]()
> in
> end
>
> Is it possible to define example$bufsz<> as a constant with late-binding?
> I suppose behavior like sizeof<a> would be ideal, but that seems to be
> internal.
>
> Thanks,
> -M
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/95cb8695-bb80-4875-84c1-efcea1eab826%40googlegroups.com.