Re: ATS mode indentation
Taking a closer look, there are definitely cases I didn't use that behave strangely. As I see it, there are four causes for this. The first is an incomplete treatment of similar constructs that should be indented the same way, e.g. datatype, dataprop, dataviewtype... I thought I had gotten this working, but I didn't test every keyword. The second is things that indent strangely at first, but indent correctly after entering calling newline-and-indent. This behavior is mildly annoying, but it is also inherited from the original SML mode and can be fixed with semicolon usage. I'm not sure SMIE is powerful enough to eradicate this behavior. The third is flat out bugs. For example, different styles of datatype declaration break indentation (i.e. | Foo of (a,b) vs | Foo() of (a,b)). The fourth is my preferred indentation style, which uses much longer lines than yours. I find it painful to read such short lines of code, and so I didn't test that case very much. For example, I would write fun {n:nat} factorial(n:int(n)): [r:int] (FACTORIAL(n,r) | int(r)) Do you have any particular examples that stood out as being incorrect? I will continue working on this for my own use, at least :) On Thursday, October 12, 2017 at 5:58:02 AM UTC-7, gmhwxi wrote: > > I gave it a try last night. I encountered many cases of excessive > indentation. > > The syntax of ATS is rich and complex. So it makes sense to require the > programmer > to manually add indentation. With the current ats-mode, you get two spaces > if you hit the > tab key. So you are pretty much in control of indentation. As far as I > know, a lot of programmers > want this kind of control :) > > > On Wed, Oct 11, 2017 at 3:43 PM, Andrew Knapp <andy.j...@gmail.com > > wrote: > >> Hello all, >> >> By cannibalizing sml.el, I have largely gotten automatic indentation >> working in ATS. >> >> After a few months of sporadic use, the only problem I couldn't fix is >> excessive indentation after a function has ended. >> This can be fixed by terminating all functions with semicolons, which is >> ugly, but it seems to work. >> If you don't do this, you have to type "fun" and then hit tab to indent >> properly. >> >> Perhaps someone with more experience with programming languages can fix >> this, since I have no background with parsers. >> (The code is based on Emacs' SMIE, which uses operator precedence >> grammars.) >> >> Here is the temporary link. Let me know what I need to do to get this >> upstream. >> >> https://github.com/ajknapp/ats-mode-indent >> >> Best, >> Andrew Knapp >> >> -- >> 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/ad0158e6-35c0-4a98-9aff-13d9a27578a6%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ats-lang-users/ad0158e6-35c0-4a98-9aff-13d9a27578a6%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/ded6ee30-3dfd-499a-ae2c-6afb8b074318%40googlegroups.com.
ATS mode indentation
Hello all, By cannibalizing sml.el, I have largely gotten automatic indentation working in ATS. After a few months of sporadic use, the only problem I couldn't fix is excessive indentation after a function has ended. This can be fixed by terminating all functions with semicolons, which is ugly, but it seems to work. If you don't do this, you have to type "fun" and then hit tab to indent properly. Perhaps someone with more experience with programming languages can fix this, since I have no background with parsers. (The code is based on Emacs' SMIE, which uses operator precedence grammars.) Here is the temporary link. Let me know what I need to do to get this upstream. https://github.com/ajknapp/ats-mode-indent Best, Andrew Knapp -- 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/ad0158e6-35c0-4a98-9aff-13d9a27578a6%40googlegroups.com.
Re: ML/OCaml style functors via includes
As a concrete example, an ATS port of the short ML example from this message would be very helpful, even if none of the functions are actually implemented. https://mail.haskell.org/pipermail/haskell/2004-August/014463.html I'd also like to know which of the features of the ML module system described in that message can be replicated in ATS, and more generally, what kind of support there is for the kind of modularity described by Robert Harper here. https://existentialtype.wordpress.com/2011/04/16/modules-matter-most/ A potential use case would be, for example, being able write code that is "functorized" over atomics and threads, with implementations like a) pthreads and c11 atomics modules for production use b) userspace threads and atomics modules, which can be subjected to randomized or exhaustive interleaving to check for concurrency bugs On Wednesday, October 18, 2017 at 1:39:50 PM UTC-7, gmhwxi wrote: > > > The following article may shed some light on this issue: > > http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/DivideConquer/main.html > > If you can tell me something a bit more concrete, I will probably be able > to say more. > > On Wednesday, October 18, 2017 at 3:53:34 PM UTC-4, Andrew Knapp wrote: >> >> >> Hello, >> >> Chapter 3 of "A Tutorial on Programming Features in ATS" mentions that >> file inclusion can be used to emulate SML or OCaml style functors in a >> limited manner. >> >> Is there an example of this technique somewhere? I would use the >> record-based functor method, as described in the make_ratmod_intmod >> example, but that has a performance cost. >> It prevents inlining and leads to calls through function pointers, both >> of which I would like to avoid. >> >> Thanks, >> Andrew >> > -- 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/6b298205-95fa-44db-bf74-21fa5d407df7%40googlegroups.com.
ML/OCaml style functors via includes
Hello, Chapter 3 of "A Tutorial on Programming Features in ATS" mentions that file inclusion can be used to emulate SML or OCaml style functors in a limited manner. Is there an example of this technique somewhere? I would use the record-based functor method, as described in the make_ratmod_intmod example, but that has a performance cost. It prevents inlining and leads to calls through function pointers, both of which I would like to avoid. Thanks, Andrew -- 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/9026b239-479f-4b4d-b84c-0ca3cedf04ae%40googlegroups.com.
Re: ATS mode indentation
What level of knowledge should the video assume? I'm guessing these are pretty new students without much emacs experience. I should have time to write a real README and do a brief video this weekend. On Friday, October 13, 2017 at 2:43:57 PM UTC-7, gmhwxi wrote: > > This looks good. > > Could you post a video on youtube to show potential users > how to set up and then use the mode? > > I will be happy to recommend it to my class. > > Thanks! > > On Friday, October 13, 2017 at 3:24:17 PM UTC-4, Andrew Knapp wrote: >> >> Both of those test cases should work now, as well as a lot of others. >> Some of the weird starting errors have been fixed, especially at the top >> level, but it won't be possible in the general case. >> Supposing you've typed >> >> let >> val foo = 3 >> >> >> there is no way for the indentation engine to know whether you will next >> type >> >> let >> val foo = 3 >> val bar = 4 >> >> or >> >> let >> val foo = 3 >> +baz() >> >> The best we can hope for is indentation that is correct after the fact. >> >> Here's the output of running indent-region on the following code. More >> test cases are welcome :) >> >> #include "share/atspre_staload.hats" >> #include "share/atspre_define.hats" >> >> extern fun imul2 >> {i,j:int}(i:int i,j:int j):<> >> [ij:int] (MUL(i,j,ij)|int ij) = "mac#imul2" >> >> extern fun atoi(!strptr): int = "mac#atoi" >> >> fun test(a:int): int = a+1 >> >> typedef qwerty = int >> typedef dvorak = double >> >> dataprop FACTORIAL(n:int,r:int) = >> | FACTORIAL_BAS(0,1) of () >> | {n:nat}{r,r1:int} FACTORIAL_IND(n,r) of >> (FACTORIAL(n-1,r1), MUL(n,r1,r)) >> >> fun factorial >> {n:nat} .<>. (n:int(n)):<> >> [r:int] (FACTORIAL(n,r) | int(r)) = >> let >> fun loop >> {i:nat|i <= n} >> {r:int} >> .. >> ( >> pf: FACTORIAL(i,r) | >> n:int n, i: int i, r: int r >> ):<> >> [r:int] (FACTORIAL(n,r) | int r) = >> if n-i>0 then >> let >> val (pfmul | r1) = imul2(i+1,r) >> in >> loop(FACTORIAL_IND(pf,pfmul) | n, i+1, r1) >> end >> else (pf | r) >> in >> loop(FACTORIAL_BAS() | n, 0, 1) >> end >> >> fun foo(): int = >> let >> fun bar(): int = >> let >> fun baz(): int = >> let >> val x = 3 >> val y = 4 >> in >> if x > 3 then >> x >> else >> y >> end >> in >> baz() >> end >> in >> bar() >> end >> >> implement main0() = let >> val x = 3 >> val (pf | res) = factorial(5) >> in >> print_list($list{int}(1,2,3,4,5)); >> println!(5); >> println!(res); >> end >> >> dataprop food = >> | MILK of () >> | EGGS of () >> >> sortdef x = {i:int | i >= 0} >> sortdef y = {i:int | i mod 2 == 0} >> >> fun bar(a:int):int = >> let >> val x = 3 >> val y = 4 >> val z = 7 >> in >> x*y+z >> end >> >> fun foo(): int = >> let >> val x = 3 >> val y = 4 >> fun loop(a:int):int = >> let >> val y = 4 >> val z = 7 >> in >> x+3 >> end >> in >> if x > 3 then 5 else 8 >> end >> >> >> >> On Thursday, October 12, 2017 at 1:31:18 PM UTC-7, aditya siram wrote: >>> >>> Huge thanks for working on this. It's difficult and tedious but sorely >>> needed. >>> >>> Here's some bad indentation cases I found: >>> sortdef even = { i:int | i mod 2 == 0 } >>>sortdef agz = {l:addr | l > null} >>> >>> >>> implement main0 () = >>> let >>> ... >>> in >>> ... >>> end >>> >>> >>> On Thursday, October 12, 2017 at 12:47:24 PM UTC-5, Andrew Knapp wrote: >>>> >>>> Taking a closer look, there are definitely cases I didn't use that >>>> behave strangely. As I see it, there are four causes for this. >>>> >>>> The f
Arrays, lists, and records
I'd like to write something like the following code: #include "share/atspre_staload.hats" #include "share/atspre_define.hats" typedef test = () -> int(* better type later *) typedef suite(data:t0ype,n:int) = @{ name = string, setup = (data -> void), teardown = (data -> void), tests = @[test][n] } fun foo_setup(a:int): void = println!("setting up") fun foo_teardown(a:int): void = println!("tearing down") fun baz(): int = let val () = println!("baz") in 3 end fun bar(): int = let val () = println!("bar") in 4 end var foo_tests = @[test][2](bar, baz) val foo : suite(int,2) = @{ name = "hello world", setup = foo_setup, teardown = foo_teardown, tests = foo_tests } implement main0() = let in println!("Hello, world!") end but the C compiler fails with these errors modules_dats.c:262:1: warning: parameter names (without types) in function declaration atstype_funptr atstyarr_field(atslab__tests) ; ^~ In file included from modules_dats.c:14:0: /usr/lib/ats2-postiats-0.3.7/ccomp/runtime/pats_ccomp_typedefs.h:176:31: error: field ‘atstyarr_field_undef’ declared as a function #define atstyarr_field(fname) atstyarr_field_undef(fname) ^ modules_dats.c:262:16: note: in expansion of macro ‘atstyarr_field’ atstype_funptr atstyarr_field(atslab__tests) ; ^~ modules_dats.c:269:1: warning: parameter names (without types) in function declaration atstype_funptr atstyarr_field(atslab__tests) ; ^~ In file included from modules_dats.c:14:0: /usr/lib/ats2-postiats-0.3.7/ccomp/runtime/pats_ccomp_typedefs.h:176:31: error: field ‘atstyarr_field_undef’ declared as a function #define atstyarr_field(fname) atstyarr_field_undef(fname) ^ modules_dats.c:269:16: note: in expansion of macro ‘atstyarr_field’ atstype_funptr atstyarr_field(atslab__tests) ; ^~ In file included from modules_dats.c:15:0: modules_dats.c: In function ‘ _057_home_057_andy_057_tmp_057_modules_057_modules_056_dats__dynload’: modules_dats.c:623:52: error: ‘postiats_tyrec_0 {aka struct }’ has no member named ‘atslab__tests’; did you mean ‘atslab__setup’? ATSINSstore_fltrec_ofs(statmp12, postiats_tyrec_1, atslab__tests, statmpref10) ; ^ /usr/lib/ats2-postiats-0.3.7/ccomp/runtime/pats_ccomp_instrset.h:321:61: note: in definition of macro ‘ATSINSstore_fltrec_ofs’ #define ATSINSstore_fltrec_ofs(tmp, tyrec, lab, val) ((tmp).lab = val) ^~ I would use viewtype lists instead of arrays, but the compiler complains about requiring fields to be of sort t0ype, not viewt0ype. Thanks, Andrew -- 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/c2552f4f-8c9a-45b3-9847-53740f4abeb6%40googlegroups.com.
Re: ATS3: ATS/Xanadu
Just some miscellaneous thoughts and questions. - Here's a paper ("Beyond Type Classes") that I found interesting. It's a generalization of Haskell's type class system that does type-directed overloading via user-defined Constraint Handling Rules (CHRs). It fits nicely with the logic metaprogramming idea, and it seems like something that would complement embeddable templates really nicely. Not sure about the type inference story. https://pdfs.semanticscholar.org/ba5c/7c7c719f5e6980b18147d19b5c31113fbb80.pdf - Getting the compiler to understand the idea of flat storage underneath a data(view)type would be really, really helpful. For example, I would like versions of constructors to be generated that take a pointer to datatype-specific flat storage, so you don't have to use malloc to construct something. Here's a quick and dirty example of what I'd like to see the compiler do. datavtype foo = | Bar of (int,int) | Baz of (string, double) // compiler would automatically generate an abstract type foo_ (foo flat) // which represents a union of Bar_pstruct(int,int) and Baz_pstruct(string,double). // the compiler would also generate symintr Bar Baz fn Bar_default(int, int):<> foo fn Baz_default(string, double):<> foo fn Bar_flat{l:addr}(!foo_?@l | ptr(l), int, int):<> foo fn Baz_flat{l:addr}(!foo_?@l | ptr(l), string, double):<> foo overload Baz Baz_default overload Baz Baz_flat overload Bar Bar_default overload Baz Bar_flat - Something like $d2ctype that gives the type of an arbitrary expression would be nice, as would a $tyrep that gave you a sort-level type description for use in templates. - Support for heterogeneous metaprogramming - sometimes it would be convenient to generate things in another language, or more generally, give existing code new meaning. This is probably the slickest thing I've used for doing that, but I don't think it would work as well in an impure language like ATS. http://conal.net/papers/compiling-to-categories/compiling-to-categories.pdf A goal would be reinterpreting subprograms to work on vectors ("SPMD on SIMD") - Edward Kmett talked about this a while ago, and he's about to start implementing it in a new functional language he'll be working on full-time. See also the Intel SPMD Program Compiler. https://www.youtube.com/watch?v=KzqNQMpRbac https://ispc.github.io/ - Here's a few things I think are good test cases for evaluating metaprogramming capabilities. How do you see ATS3 solving the following problems, if at all? * automatically deriving (de)serialization for records and datatypes * generating parsers or API bindings from an XML description (sadly, XML is how many such things are provided) * given a skeleton of an algorithm for, say, matrix multiplication (parameterized by things like loop tiling depth, unrolling amount, etc.), generate a bunch of instantiations with different parameter choices, run and benchmark them, and use/save the best one -- 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/c137a67c-3a81-4b3b-a34d-d579b32bd665%40googlegroups.com.
Re: Shared memory IPC in ATS
Nanomq is as bare-bones as you can possibly get. Unlike zeromq, it only works for a small number of local processes, and makes every possible tradeoff for low latency. Nanomq (in the ATS port and original C++) only offers blocking reads in the public interface (I'll probably change this), which are implemented via spin locks. Fun fact: nanomq doesn't even use atomics -- with SPSC ring buffers, you can get away with only a compiler fence for reads and a store fence for writes on x86! -- 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/de69e1e6-5e85-44de-b93d-5f9505f9171f%40googlegroups.com.
Shared memory IPC in ATS
Hi all, I've extracted some ipc code from a larger codebase. https://github.com/ajknapp/ats-nanomq It's basically a bunch of SPSC ring buffers in shared memory, and is ported from a C++ library https://github.com/rigtorp/nanomq Fair warning: there aren't many scenarios where this design is a good idea, and the code also uses a few more unsafe things than I think would be necessary if I knew ATS better (e.g. the head pointer). -- 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/68d837ee-dd85-4f25-b24b-016904922bd4%40googlegroups.com.
Re: Functions from datasorts to datasorts
My one example, serialization of nested records from a tlist of @(string,t0ype), turned out to not need append. Anyhow, that's blocked for now, since I don't think you can reflect a template-argument string literal to the value level. But more generally, a convenient way to write functions between datasorts would be a large step towards very powerful metaprogramming in ATS. With a few more features, ATS could have a very clean and conceptually simple metaprogramming approach: templates are interpreters for datasorts. Just like a value-level interpreter, it would be nice to separate generation and evaluation stages. People wrote Boost Hana in C++ to do all kinds of computation on type-level data structures, despite how painful C++ metaprogramming is. https://www.boost.org/doc/libs/1_61_0/libs/hana/doc/html/index.html ATS is not that far from being Boost.Hana on steroids. The typechecking is already there, and is SO. MUCH. BETTER. than the mess you get when trying to write untyped purely functional programs in C++ templates. For example, if you pass a bool to a template that expects a tlist, the compiler tells you exactly what happened. -- 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/a6a26a70-7b0c-4465-8e0c-f20f2fdba6e0%40googlegroups.com.
Re: Flat memory underlying dataviewtypes
I'll put it on github sometime this week. It's an ATS port of this c++ library https://github.com/rigtorp/nanomq -- 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/73f0ab46-9e7b-4d16-984a-c9a603ee8972%40googlegroups.com.
Re: ATS3: ATS/Xanadu
After writing several thousand lines of ATS, I'd say there isn't terribly much I'd change, honestly. A lot less than when I got started, for sure. What I would like to see changed: 1. Real module system. MixML might not be a bad source of inspiration, as it would essentially be a better version of the ML "modules" you can fake with includes, e.g. funmap.hats, and there's an implementation available. Doing away with the sigil before module names would be nice. 2. Naming conventions in standard library changed. Less g0ofg1, i2r and so on would be nice. I also find the abbreviations you choose to be very difficult to read. With a real module system, it would be nice to have shorter function names: you could get away with Array.map or A.map instead of array_map. This way the user can choose how verbose to be about module names. 3. Integrating templates with the module system. BTW embeddable templates are my absolute favorite feature of ATS. 4. Accessing flat memory of sum types and some kind of analog of C++ placement new. This would make certain things a lot safer and easier. 5. Real macros or very powerful metaprogramming support. I know metaprogramming can be abused, but there are many things where I wish I had even a customizable version of #codegen2 that I could use. D is probably a good source of inspiration for this subject. 6. General cleanup of cruft and making sure features work together. 7. Pretty-printed error messages. 8. REPL, perhaps via atscc2scm and an embedded R7RS-small interpreter? Anyways, I've found ATS to be a real pleasure to use overall, and I trust my code is correct a lot more than in C++. -- 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/1b0f9f4f-51c3-46db-94a1-b0c91d1e4f9c%40googlegroups.com.
Re: Flat memory underlying dataviewtypes
The code on glot also fails if you change Bar to Baz in all the appropriate places. -- 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/55f6d7ff-167d-4a96-be75-5761dbf88908%40googlegroups.com.
Re: Flat memory underlying dataviewtypes
Yes, that works well. Thank you! -- 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/ec46aa79-2ad7-468f-bebb-1a4da358ec5e%40googlegroups.com.
Flat memory underlying dataviewtypes
Hello, I'd like to be able to send dataviewtypes as messages in a low-latency ipc library I've written. In this scenario, any use of malloc is unacceptable. Everything must be allocated from a memory pool or the stack, but datavtype constructors always allocate on the heap. What is the best way to access to the size and flat memory of the datavtype's tagged union, preferably in a typesafe manner? You can do this by a hack like dataviewtype message = | Bar of (int, double) | Baz of (double, double) #define BAR 0 #define BAZ 1 typedef BAR_ = @{ contag = int, atslab__0 = int, atslab__1 = double } typedef BAZ_ = @{ contag = int, atslab__0 = double, atslab__1 = double } and then using $UNSAFE.cast{Foo} on a pointer to stack or pool allocated memory of size FOO_SIZE = max(sizeof, sizeof), which has had its contag set to BAR or BAZ via another unsafe cast. Unfortunately there is really a lot of boilerplate here and it will be easy for things to get out of sync with datatype definitions, especially with a lot of constructors. Moreover, FOO_SIZE is not a static constant, so you can't just write something like var buf : @[char][FOO_SIZE*N] Also, is there an equivalent of the placement new operator in C++? Thanks, Andrew -- 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/51b38545-377a-445a-9e3c-2086e760a680%40googlegroups.com.