Slightly neater. Note that you can have cover (multiple; expressions) with 
a single where {}

#include "share/atspre_staload_hats."

implement main0() = example<int>() where {
  #define example$bufsz 100
  #include "./testarr.hats"
}


On Tuesday, September 25, 2018 at 3:46:17 PM UTC-5, Julian Fondren wrote:
>
> 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 ats-lang-users+unsubscr...@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
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/88c64df5-d9b6-4df4-becd-f0b7b70f2603%40googlegroups.com.

Reply via email to