--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/6b594d79-3ebb-41a7-83b3-72490726b4e5o%40googlegroups.com.
Part 2:
I will soon be starting to work on Part 2 after taking a break, hoping
to finish something that can be tested at the end of the Summer.
Part 3:
This part essentially does type-checking involving linear types and
dependent types. Hopefully, I will be able to get a running implementation
by the Spring next year.
######
Based on what I have experimented so far, I find the current support
for templates in ATS3 to be a game-changing programming feature that
can greatly increase one's programming productivity. I am a bit amazed
by it :) If you think that the templates in C++ are powerful, then you
will find that the templates in ATS3 are even more powerful in many
aspects. Actually, not only just more powerful but also a great deal
safer. Keep tuned.
Cheers!--Hongwei
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/8fb6bfae-872a-416a-8ad2-4e1281161ebfo%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-users+unsubscribe@googlegroups.com.
C++ templates restricted to functions show only one half oft the truth.
template<typename T>
struct function;
struct XXX;
template<>
struct function<XXX> {
template<typename... A>
void operator()(std::ostream& s, const A&... a) {
(s << ... <<
a);
}
};
struct YYY;
template<>
struct function<YYY> {
template<typename... A>
void operator()(const A&... a) {
(std::cout << ... <<
a);
}
};
int main()
{
//using function object - additional constructor parenthesis
function<XXX>()(std::cout,"a",1);
function<YYY>()(1,"a");
return 0;
}
Template power in c++ starts with structs or classes and
templated normal functions
are often used to redirect the call to templated structs and their
specializations. Where
structs/classes may have many also templated methods and many
inner classes and
yes a function - I think - can have inner structs:
void my_function()
{
struct abc { void print() { std::cout << "ok" <<
std::endl; } };
abc().print();
}
Template are not a weak point in C++. But if you look in
direction of category theory, one can
very quickly recognize, that this topic is a black hole. C++ has
no mathematical inspiration and
the same is most the time true for the programmers.
Perhaps I could transport a little bit more on c++ template
feelings.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/503d7a16-7ae4-4a6d-94ad-9ef51fd35a22o%40googlegroups.com.
A lambda is a shortcut for a function object with exactly on parenthesis operator implemented
struct function
{
function(int k) : j(k) {}
void operator(auto i) { cout << i << "/" <<
k << endl; }
int j;
};
application: function(1)(2) or in two steps auto f = function(1);
f(2)
lambda:
auto j = 1
auto f = [j](int i) { cout << i << "/" << j
<< endl; };
The capture copy j is like the member j of struct function.
application: f(2)
Therefore it's clear if I can use a lambda within a normal
c-function it must be possible
to declare a class/struct within a function - if there is some
logic behind.
So now I'm complete.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/69d08849-2a62-52fb-6d42-b9d8d1d4a954%40bejocama.de.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CALn1vHEpfccad3EydBsRjLsoxWo%3DgBgUGQVfD-naT9BYqTeqOQ%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/8fb6bfae-872a-416a-8ad2-4e1281161ebfo%40googlegroups.com.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/503d7a16-7ae4-4a6d-94ad-9ef51fd35a22o%40googlegroups.com.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/69d08849-2a62-52fb-6d42-b9d8d1d4a954%40bejocama.de.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/8fb6bfae-872a-416a-8ad2-4e1281161ebfo%40googlegroups.com.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/503d7a16-7ae4-4a6d-94ad-9ef51fd35a22o%40googlegroups.com.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/69d08849-2a62-52fb-6d42-b9d8d1d4a954%40bejocama.de.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/4d182002-b7ce-fc52-1610-23a122a7671c%40bejocama.de.
>>I'm wondering how are ATS3 templates different from ATS2 templates?Here is a simple but very telling example:fun<a:type><n:int>array_length(A0: array(a, n)): int(n)The type array(T, N) is for a C-array of size N for storing values of type T.Given that the size information of a C-array is not attached to the array, the functionarray_length can only be implemented in a context where the size information can beobtained in some manner.In ATS3 (but not in ATS2), we can implement a template of the following interface:fun<a:type>foo{n:int}(A0: array(a, n)): voidIn ATS2, we have to change the interface tofun<a:type>foo{n:int](A0: array(a, n), size: int(n)): voidIn other words, in ATS3, the size of a C-array does not have to be passed together withthe C-array; it can be "gleaned" from the context instead.
By the way, I remember you once asked a question on the tabulate function template. InATS3, it can finally be properly done:fun<a:type><n:int>tabulate(): list(a, n)fun<a:type><n:int>tabulate$for{i:nat | i < n}(int(i)): aHere is some running code that could clarify further:
Cheers!
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lan...@googlegroups.com.
Yes correct.
In c++ declaration and implementation must be in the same
namespace and
templates in blockscope are in general not allowed.
Yes I know the late binding section of the ats documentation. ATS
developpers
should be happy to have it. Functional constructions are more
lightweight than
c++ object oriented ones.
Looking on this example I think c programmers could like it more
then c++
programmers.
regards, matthias
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLrm6kr5NOjpd-9nNk%2B0cVxMdYEJYVt3knA6wq%3DZagLLvg%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lan...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/8fb6bfae-872a-416a-8ad2-4e1281161ebfo%40googlegroups.com.
--
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-lan...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/f8215610-16ee-4dec-bb75-082b8bc666c1n%40googlegroups.com.