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 <abysgr...@gmail.com> 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/b5bd37d6-cfe7-4a30-a956-b8aada50a005%40googlegroups.com
> <https://groups.google.com/d/msgid/ats-lang-users/b5bd37d6-cfe7-4a30-a956-b8aada50a005%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAPPSPLo5VtOpc6hSRDbCC%3DipNiObX5P58OoNM6_w8gOQretyBQ%40mail.gmail.com.

Reply via email to