Re: how does $list(...) work ? Can I make my own vararg function ?
Nice ! пятница, 10 ноября 2017 г., 20:57:34 UTC+3 пользователь gmhwxi написал: > FYI. > > I have just added some support for using variadic functions in ATS. > Here is a running example: > > https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/TESTATS/variadic.dats > > The changes to ATS/Postiats are planned to to into the next release of ATS > (ATS2-0.3.8). > > Cheers! > > On Tuesday, November 7, 2017 at 5:15:35 PM UTC-5, gmhwxi wrote: > > $list is handled specially. Another one is $arraypsz > (for creating linear arrays). > > I read various messages posted in this group and realized that > variadic functions are not yet supported. I will now try to add some > support for variadic functions so that it can go into the next release. > > In ATS1, one can implement variadic functions in a type-safe manner. > I do not plan to support this yet in ATS2. What I plan to do is to support > calling (not implementing) variadic functions in ATS2 in a type-safe manner. > > Cheers! > > On Sunday, November 5, 2017 at 7:51:26 AM UTC-5, Russoul wrote: > As I understand varargs are not supported in ATS2 ? But $list and similar > functions somehow use this feature. How does it work ? -- 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/b1bae4a6-b130-411c-be9c-a0358ba4e170%40googlegroups.com.
how does $list(...) work ? Can I make my own vararg function ?
As I understand varargs are not supported in ATS2 ? But $list and similar functions somehow use this feature. How does it work ? -- 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/562f9633-3dee-4471-a9ed-eea915e0fa0e%40googlegroups.com.
Is it possible to return array by value?
Is it possible to return array by value? -- 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/1a5e936e-4a89-4691-b127-2505d36ce2b5%40googlegroups.com.
Re: Why compiler can't choose between overload of fun, cloref and cloptr at call site
There should be 'foreach' in above example вторник, 24 октября 2017 г., 19:19:22 UTC+3 пользователь Russoul написал: > > Ok, then is there a way to cast 'fun' to 'cloref' ? > For example, in this scenario: "list0_map_cloref(xs, println)" > > Only this way : "list0_map_cloref(xs, lam x => println x)" ? > > The first line just looks more natural > > вторник, 24 октября 2017 г., 19:05:16 UTC+3 пользователь gmhwxi написал: >> >> Yes, you can. >> >> But this looks "unconventional". I remember that ATS did use >> function/cloref >> information to resolve overloading at some point, but it did not do well >> in practice >> as users were often confused when overloading did not work as they had >> expected. >> >> For functional programming (with GC), one really just need >> list0_map_cloref. >> >> For a setting where GC is not supported or desirable, one should probably >> use the >> template version of list_map. >> >> On Tuesday, October 24, 2017 at 11:40:06 AM UTC-4, Russoul wrote: >>> >>> But one can specify the type like that : "lam(x) = ...", no ? >>> >>> вторник, 24 октября 2017 г., 18:17:16 UTC+3 пользователь gmhwxi написал: >>>> >>>> >>>> Because this kind of information is not used to resolve overloading. >>>> >>>> Imagine that you write >>>> >>>> list0_map(xs, lam(x) => ...) >>>> >>>> It is not clear whether 'lam(x) => ...' is a function, closure or >>>> linear closure. >>>> >>>> On Tuesday, October 24, 2017 at 11:02:56 AM UTC-4, Russoul wrote: >>>>> >>>>> Suppose we have "list0_map_fun, list0_map_cloref, list0_map_cloptr" >>>>> higher order functions. >>>>> And then we overload "list0_map" with all those. Why compiler gives : >>>>> "the symbol [list0_map] cannot be resolved due to too many matches" when >>>>> used with one of [fun,cloref,clopth] function types ? >>>>> >>>> -- 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/67914d6e-f0eb-48d0-ac2c-347caa6d50d1%40googlegroups.com.
Re: Why compiler can't choose between overload of fun, cloref and cloptr at call site
Ok, then is there a way to cast 'fun' to 'cloref' ? For example, in this scenario: "list0_map_cloref(xs, println)" Only this way : "list0_map_cloref(xs, lam x => println x)" ? The first line just looks more natural вторник, 24 октября 2017 г., 19:05:16 UTC+3 пользователь gmhwxi написал: > > Yes, you can. > > But this looks "unconventional". I remember that ATS did use > function/cloref > information to resolve overloading at some point, but it did not do well > in practice > as users were often confused when overloading did not work as they had > expected. > > For functional programming (with GC), one really just need > list0_map_cloref. > > For a setting where GC is not supported or desirable, one should probably > use the > template version of list_map. > > On Tuesday, October 24, 2017 at 11:40:06 AM UTC-4, Russoul wrote: >> >> But one can specify the type like that : "lam(x) = ...", no ? >> >> вторник, 24 октября 2017 г., 18:17:16 UTC+3 пользователь gmhwxi написал: >>> >>> >>> Because this kind of information is not used to resolve overloading. >>> >>> Imagine that you write >>> >>> list0_map(xs, lam(x) => ...) >>> >>> It is not clear whether 'lam(x) => ...' is a function, closure or linear >>> closure. >>> >>> On Tuesday, October 24, 2017 at 11:02:56 AM UTC-4, Russoul wrote: >>>> >>>> Suppose we have "list0_map_fun, list0_map_cloref, list0_map_cloptr" >>>> higher order functions. >>>> And then we overload "list0_map" with all those. Why compiler gives : >>>> "the symbol [list0_map] cannot be resolved due to too many matches" when >>>> used with one of [fun,cloref,clopth] function types ? >>>> >>> -- 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/374c0d16-3d31-43e4-9419-f721e708034d%40googlegroups.com.
Re: Why compiler can't choose between overload of fun, cloref and cloptr at call site
But one can specify the type like that : "lam(x) = ...", no ? вторник, 24 октября 2017 г., 18:17:16 UTC+3 пользователь gmhwxi написал: > > > Because this kind of information is not used to resolve overloading. > > Imagine that you write > > list0_map(xs, lam(x) => ...) > > It is not clear whether 'lam(x) => ...' is a function, closure or linear > closure. > > On Tuesday, October 24, 2017 at 11:02:56 AM UTC-4, Russoul wrote: >> >> Suppose we have "list0_map_fun, list0_map_cloref, list0_map_cloptr" >> higher order functions. >> And then we overload "list0_map" with all those. Why compiler gives : >> "the symbol [list0_map] cannot be resolved due to too many matches" when >> used with one of [fun,cloref,clopth] function types ? >> > -- 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/85e571c1-7b42-4240-a7e2-68c2634dd1ae%40googlegroups.com.
Why compiler can't choose between overload of fun, cloref and cloptr at call site
Suppose we have "list0_map_fun, list0_map_cloref, list0_map_cloptr" higher order functions. And then we overload "list0_map" with all those. Why compiler gives : "the symbol [list0_map] cannot be resolved due to too many matches" when used with one of [fun,cloref,clopth] function types ? -- 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/d1dd3ead-d307-4699-8c6e-6b1c069f010b%40googlegroups.com.
Re: Ergonomics question
About 'val's, in cases when 'val' is used only to bind void result of some expression why can't we omit 'val () =' part ? And I still don't understand how 'val' helps with explicit notation of whether a value is recursively defined or not. Could you explain it a bit further ? Missed the fact that 'where' is supported, sorry. вторник, 24 октября 2017 г., 3:36:41 UTC+3 пользователь gmhwxi написал: > > > The let-in-end construct is borrowed from ML: ATS can be said > to belong to the ML family of functional programming languages. > > In a call-by-value language, one needs to explicitly specify whether > a value is recursively defined or not. If you don't use 'val', then you > need something else. For instance, one may need to have both let and > letrec. > > By the way, ATS support 'where', too: > > fun f(x: int): int = y where { val y = x + x } > > On Monday, October 23, 2017 at 2:59:09 PM UTC-4, Russoul wrote: >> >> It is probably a useless question but why do we have "let in end" >> construct in ats? It is verbose and you have to write a new one in each >> inner scope, for example inside "if else" statement. Haskell goes well >> just with "let in" plus it has "where" which is very neat sometimes. >> >> And also "val _ =..."'s go crazy sometimes. >> >> ATS is very expressive which already leads to increased code size. >> >> -- 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/ab93b57f-f265-4d7c-a93e-437c605a4068%40googlegroups.com.
Re: Best way to handle short-living linear objects
Yes, but that is not modular. What if I need the inputs later ? Then I'll have to copy them. Consuming the inputs is also a bit confusing. пятница, 20 октября 2017 г., 17:21:27 UTC+3 пользователь Steinway Wu написал: > > I guess you can define \cross and * as functions that consume the linear > lists and return a new one? > > On Friday, October 20, 2017 at 10:11:00 AM UTC-4, Russoul wrote: >> >> Let's treat `list_vt(a,n)` as algebraic vector of dim 'n'. Then let's >> perform some operations on a bunch of them: >> >> (*pseudocode*) >> ... >> val a = $list_vt(1,0,0) >> val b = $list_vt(0,1,0) >> val c = a \cross b >> val d = c * PI >> ... >> val _ = free a >> val _ = free b >> val _ = free c >> val _ = free d >> (*end of code fragment*) >> >> Cleaning(freeing) after simple algebraic operations in the above example >> is tedious. And I suppose it can become a real pain in math extensive code. >> What is the way out ? >> >> -- 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/859ccbb6-1a42-4404-81af-25f3a4ce4f37%40googlegroups.com.
Best way to handle short-living linear objects
Let's treat `list_vt(a,n)` as algebraic vector of dim 'n'. Then let's perform some operations on a bunch of them: (*pseudocode*) ... val a = $list_vt(1,0,0) val b = $list_vt(0,1,0) val c = a \cross b val d = c * PI ... val _ = free a val _ = free b val _ = free c val _ = free d (*end of code fragment*) Cleaning(freeing) after simple algebraic operations in the above example is tedious. And I suppose it can become a real pain in math extensive code. What is the way out ? -- 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/0506aede-b032-43ea-bb9d-f97391015285%40googlegroups.com.
Re: convert primitives (int,float,...) to string (or linear string). Convert native char* to string and reversed ?
Thank you for your help -- 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/1fddad8e-de07-4cb1-9a72-dfdb05738909%40googlegroups.com.
Re: convert primitives (int,float,...) to string (or linear string). Convert native char* to string and reversed ?
So if I have ATS running with libgc, a char* allocated with libc in embedded into ATS C code and then I cast char* to string: $UN.cast{string}(ptr) . I still have a string that is located in not garbage collected heap, so i have to free it explicitly, correct ? Same with strptr but ATS compiler backs me up and ensures that I free it . суббота, 7 октября 2017 г., 15:58:08 UTC+3 пользователь gmhwxi написал: > > > What I was trying to say is that malloc/free is external to ATS; > it is not baked into ATS. > > If you use libgc for malloc/free, you get GC from libgc. If you use, > say, libc for malloc/free, then you don't have GC. > > On Saturday, October 7, 2017 at 8:48:53 AM UTC-4, Russoul wrote: >> >> Sorry, I'm a bit lost now ) Right, ATS has no GC. But it can generate C >> code that can be linked with libgc with D_ATS_GCATS, right ? Or I'm >> still missing something ? >> суббота, 7 октября 2017 г., 15:04:09 UTC+3 пользователь gmhwxi написал: >>> >>> >>> ATS has no GC. >>> >>> You can use libgc to do malloc/free needed in the C code generated >>> from ATS source. In that way, you get GC from libgc. >>> >>> You can also do $UNSAFE.castvwtp0{Strptr1}(pointer) to get a linear >>> string. >>> Then you need to explicitly free the linear string at some point in your >>> program >>> (or cast it into a non-linear string). >>> >>> >>> On Sat, Oct 7, 2017 at 7:56 AM, Russoul <russ...@gmail.com> wrote: >>> >>>> And how to correctly convert char* to string ? Just >>>> $UNSAFE.cast{string}(pointer) ? Will the original char* be GCed by ATS ? >>>> >>>> суббота, 7 октября 2017 г., 14:33:13 UTC+3 пользователь gmhwxi написал: >>>>> >>>>> >>>>> Assuming that you are targeting C. I would suggest that you use >>>>> snprintf >>>>> (plus $UNSAFE.cast). >>>>> >>>>> On Saturday, October 7, 2017 at 5:40:01 AM UTC-4, Russoul wrote: >>>>>> >>>>>> convert primitives (int,float,...) to string (or linear string). >>>>>> Convert native char* to string and reversed ? >>>>>> >>>>> -- >>>> 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/db92b4d8-58aa-4033-a446-d4f009c0215c%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/ats-lang-users/db92b4d8-58aa-4033-a446-d4f009c0215c%40googlegroups.com?utm_medium=email_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/099f9297-ce38-428b-b359-3a7275e34425%40googlegroups.com.
Re: convert primitives (int,float,...) to string (or linear string). Convert native char* to string and reversed ?
Sorry, I'm a bit lost now ) Right, ATS has no GC. But it can generate C code that can be linked with libgc with D_ATS_GCATS, right ? Or I'm still missing something ? суббота, 7 октября 2017 г., 15:04:09 UTC+3 пользователь gmhwxi написал: > > > ATS has no GC. > > You can use libgc to do malloc/free needed in the C code generated > from ATS source. In that way, you get GC from libgc. > > You can also do $UNSAFE.castvwtp0{Strptr1}(pointer) to get a linear string. > Then you need to explicitly free the linear string at some point in your > program > (or cast it into a non-linear string). > > > On Sat, Oct 7, 2017 at 7:56 AM, Russoul <russ...@gmail.com > > wrote: > >> And how to correctly convert char* to string ? Just >> $UNSAFE.cast{string}(pointer) ? Will the original char* be GCed by ATS ? >> >> суббота, 7 октября 2017 г., 14:33:13 UTC+3 пользователь gmhwxi написал: >>> >>> >>> Assuming that you are targeting C. I would suggest that you use snprintf >>> (plus $UNSAFE.cast). >>> >>> On Saturday, October 7, 2017 at 5:40:01 AM UTC-4, Russoul wrote: >>>> >>>> convert primitives (int,float,...) to string (or linear string). >>>> Convert native char* to string and reversed ? >>>> >>> -- >> 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/db92b4d8-58aa-4033-a446-d4f009c0215c%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ats-lang-users/db92b4d8-58aa-4033-a446-d4f009c0215c%40googlegroups.com?utm_medium=email_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/9dc34d25-c2cc-44b3-ade7-f7ea21b2f2bd%40googlegroups.com.
Re: convert primitives (int,float,...) to string (or linear string). Convert native char* to string and reversed ?
And how to correctly convert char* to string ? Just $UNSAFE.cast{string}(pointer) ? Will the original char* be GCed by ATS ? суббота, 7 октября 2017 г., 14:33:13 UTC+3 пользователь gmhwxi написал: > > > Assuming that you are targeting C. I would suggest that you use snprintf > (plus $UNSAFE.cast). > > On Saturday, October 7, 2017 at 5:40:01 AM UTC-4, Russoul wrote: >> >> convert primitives (int,float,...) to string (or linear string). Convert >> native char* to string and reversed ? >> > -- 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/db92b4d8-58aa-4033-a446-d4f009c0215c%40googlegroups.com.
convert primitives (int,float,...) to string (or linear string). Convert native char* to string and reversed ?
convert primitives (int,float,...) to string (or linear string). Convert native char* to string and reversed ? -- 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/475cfaeb-5cce-4b86-bc9a-04ce13a2a2ef%40googlegroups.com.
implement template based function on dependent type
Say, I have a function: extern fun{a:t@ype} minus(x : a, y : a) : a And : extern fun{a:t@ype} list_minus {n:nat} (xs : list(a,n), ys : list(a,n)) : list(a,n) How can I implement [minus] for list(a,n) ? I have it this far: implement(a) minus(x,y) = list_minus(x,y) But that does not guarantee that [x] and [y] have the same [n:nat] : unsolved constraint: C3NSTRprop(C3TKmain(); S2Eeqeq(S2Evar(n$3372$8590(14716)); S2Evar(n$3371$8589(14715 -- 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/19e2dfbd-fe6b-4f41-a520-76a834d8e44a%40googlegroups.com.
VAR
How does *var* work ? *var i : list(int,2) with pi = list_cons(1,list_nil)* does it really allocate a list on stack ^^ ?? -- 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/51c11554-1d2e-454f-abc1-60484330519e%40googlegroups.com.