For now, I have found the only way to achieve my goal is by using boxed
tuples/boxed records:

vtypedef VT = (array_v(char?,l,recv_sz) | '( ptr l, size_t recv_sz))
(*...*)
var tmp = (recv_buf_pf | '( recv_buf, recv_sz))

I don't know if this a best way though, as I suppose, that boxed tuple is
heap-allocated and I don't know how to cleanup such tuple without GC

чт, 9 июл. 2020 г. в 23:54, Dambaev Alexander <[email protected]>:

> And again, I had mistyped one thing in initial email:
>
> (* ... *)
> var tmp = (recv_buf_pf | recv_buf) (* var instead of val in both similar
> lines *)
> (* ... *)
>
>
> чт, 9 июл. 2020 г. в 23:47, [email protected] <[email protected]>:
>
>> Hi,
>>
>> I am trying to understand how to use array_foreach_env function to pass
>> to fwork environment of more than 1 variables (of viewt@ype).
>> For example, I can successfully use following:
>>
>> vtypedef VT = (array_v(char?, l, recv_sz | ptr l)
>> fn walker
>>     ( array_v(pollfd_t, fdsl, nfds)
>>     , x : &pollfd_t >> _
>>     , env: !VT
>>     ): void =
>>     (* body goes here *)
>>
>> val tmp = (recv_buf_pf | recv_buf)
>> val () = array_foreach_funenv
>>                <pollfd_t>
>>                {array_v(pollfd_t, fdsl,nfds)}
>>                {VT}
>>                ( fds_pf | fds, nfds, walker, tmp)
>> val (recv_buf_pf | _) = tmp
>>
>> But, as soon as I want to use VT of type
>> vtypedef VT = (array_v(char?, l, recv_sz) | ptr l, size_t recv_sz)
>> (* ... *)
>> val tmp = (recv_buf_pf | recv_buf, recv_sz)
>> (* .. *)
>> val (recv_buf_pf | _) = tmp
>>
>> I am getting the following error:
>> error(3): mismatch of sorts:
>> the needed sort is [S2RTbas(S2RTBASimp(2; viewtype))];
>> the actual sort is [S2RTbas(S2RTBASimp(3; viewt0ype))].
>>
>> How can I fix this error? Thanks in andvance
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "ats-lang-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/ats-lang-users/A60YvQACw4c/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ats-lang-users/6826800e-17e0-4554-8470-3a7e304bc71bn%40googlegroups.com
>> <https://groups.google.com/d/msgid/ats-lang-users/6826800e-17e0-4554-8470-3a7e304bc71bn%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KzgHoKJMAVypUCv17xYrB%2BFoycUySXYJknvrNVackkGqw%40mail.gmail.com.

Reply via email to