In general, if you want to call a C function in ATS,
you can just use 'extfcall' for external function calls.
Of course, if you do so, you bypass ATS type-checking.
Here is an example:

%{^
int lsl(uint u, int n) { return (u << n); }
int lsr(uint u, int n) { return (u >> n); }
%}

implement
main0() =
{
val
pow_2_10 =
$extfcall(uint, "lsl", 1, 10)
val () = println!("pow_2_10 = ", pow_2_10)
}

On Wed, Jul 8, 2020 at 10:56 AM Dambaev Alexander <ice.redm...@gmail.com>
wrote:

> Thanks, I will check it out
>
> ср, 8 июл. 2020 г. в 14:30, Hongwei Xi <gmh...@gmail.com>:
>
>> You can find these operations in prelude/SATS/integer.sats
>> There are called:
>> lnot (for ~),
>> land (for &), lor (for |), lxor (for ^), lsl (for <<), and lsr (for >>).
>>
>> These operations are for unsigned ints. For signed ints, there
>> are asl (for <<) and asr (for >>).
>>
>> In ATS2, there is no implicit casting. You may have to cast a
>> signed int into an unsigned int explicitly in order to perform a bit
>> operation.
>>
>>
>> On Wed, Jul 8, 2020 at 5:33 AM ice.r...@gmail.com <ice.redm...@gmail.com>
>> wrote:
>>
>>>
>>> Hi,
>>> I was not able to find bit operations
>>> in ATS, like &, |, <<, >>.
>>>
>>> Does ATS supports them?
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ats-lang-users/04b44a32-88e3-4855-acb9-ed7bdcc3391en%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ats-lang-users/04b44a32-88e3-4855-acb9-ed7bdcc3391en%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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLr4FG-ai8xBPn-C4ZPQiXxYr0gjmLNcpy%3DcnG6ydivyVA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLr4FG-ai8xBPn-C4ZPQiXxYr0gjmLNcpy%3DcnG6ydivyVA%40mail.gmail.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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KzT18QD6_GYseq2guD_%3DQ8aMwnwKHhW8dqC%3DTJfLN7aHg%40mail.gmail.com
> <https://groups.google.com/d/msgid/ats-lang-users/CAHjn2KzT18QD6_GYseq2guD_%3DQ8aMwnwKHhW8dqC%3DTJfLN7aHg%40mail.gmail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLqSbMjt-1pbGP-D-4%3DkZgJkrGbae3azsAQ3rc6RhRS-Rg%40mail.gmail.com.

Reply via email to