extern fn sqrt( double) :<> double = "ext#"
extern fn launch_missles( double) :<> double = "ext#"
We can define external call as effectless (as I understand, this means "pure" in terns of ATS2);
extern fn sqrt( double) :<> double = "ext#"
extern fn launch_missles( double) :<> double = "ext#"
I do understand, that this is due to goal to make transition from C to ATS to be less painful, but maybe, there should be some flag (like -XSafe for ghc, or maybe -Wall -Werror), which will treat effectless ffi calls to be compile time errors?
And one more generic question: I haven't got if user can introduce new custom effects or are they just a predefined set of effects? Are there any docs about such topics in ATS?
--
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-user...@googlegroups.com.
To post to this group, send email to ats-lan...@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/c440ad8c-9322-44ca-ba6e-c3aaeabe0ece%40googlegroups.com.
I do understand, that this is due to goal to make transition from C to ATS to be less painful, but maybe, there should be some flag (like -XSafe for ghc, or maybe -Wall -Werror), which will treat effectless ffi calls to be compile time errors?
And one more generic question: I haven't got if user can introduce new custom effects or are they just a predefined set of effects? Are there any docs about such topics in ATS?
Oops, did not see you responded Artyom!
fun double (n: int) :<1> int = n + n
val () = println! ("double(5) = ", double(5))
#include "share/atspre_staload.hats"
implement main0() = ()
// If I am not mistaken, all functions in ats have all effects (i.e. :<1>) by default.
// note, :<0> is equivalent to :<>
// Just some thoughts....
fun terminating .<>. (n: int):<> int = n * n
//// Here we require to provide proof that the function terminates// so, we just insist that it does (.<>.)//// Well it does not seem to be a very effectful function so sure// though, what is the significance of purity in this case?//// Effects tracking in ats is not exactly a contract// For example,
val terminate = terminating(0xb505)
//// This typechecks fine however, do you notice something strange about the resulting value?// Passing a value larger than the square root of INTMAX causes arithmetic overflow...//// In this case, what good is a function annotated as pure if it can produce arithmetic overflow?//// Let us look at a different example, lets use dependent types to flush out this potential bug...//
stadef IMAX = 2147483647
fun dependent {n:int | n*n <= IMAX} (n: int(n)): int(n*n) = n*n
// 'depend' below fails typechecking,// unsolved constraint:// (46341 * 46341) <= IMAXval depend = dependent(0xb505)
// however this typechecks,val depend = dependent(0xb504)
Hi Guys, Thanks for the discussion.As usual I don't fully understand or recall some of the relevant issues.In the online editor I quickly tried out this:
fun double (n: int) :<1> int = n + n
val () = println! ("double(5) = ", double(5))Which works. But changing :<1> to :<0> fails to compile; i also tried a non-polymorphic identity function for ints and had the same result. So what does :<0> really mean?I think if we had (1), a way to keep track of purity, i.e., any expressions returning unit must be equivalent to the expression () (hopefully this isn't hard to check..), and (2), a way to tell the compiler to assume that ":" assumes :<0> by default, then we might just get purity checking done for free.
implement
main0 () = {
val () = println! ("double(5) = ", double(5))
}
fun double .<>. (n: int) :<0> int = (
// print 'h';
n + n
)
fun double .<>. (n: int):<> int =( $effmask{1}(print 'h'); n + n)
main0 = program
--
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-user...@googlegroups.com.
To post to this group, send email to ats-lan...@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/1c4e3296-1c65-4685-b897-020bf297c5a7%40googlegroups.com.