Introduction to function templates

I added a chapter on function templates in my Intro-to-ATS book:

http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/HTMLTOC/

This chapter is in Part V of the book, and it is still being worked.
However, it can
already provide a lot of useful information on function templates in ATS.
Cheers!

The long awaited chapter :). Looking forward to itOn Sun, Mar 8, 2015 at 2:06 PM, gmhwxi gmh...@gmail.com wrote:

I added a chapter on function templates in my Intro-to-ATS book:

Introduction to Programming in ATS

This chapter is in Part V of the book, and it is still being worked.
However, it can
already provide a lot of useful information on function templates in ATS.
Cheers!


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 http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/85e05133-4905-40e9-90af-8a2a4b57d05a%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/85e05133-4905-40e9-90af-8a2a4b57d05a%40googlegroups.com?utm_medium=email&utm_source=footer
.

Brandon Barker
brandon...@gmail.com

I added a chapter on function templates in my Intro-to-ATS book:

Introduction to Programming in ATS

This chapter is in Part V of the book, and it is still being worked.
However, it can
already provide a lot of useful information on function templates in ATS.
Cheers!

Great work!

I have a question: why do you use list0 in the myprint example? Why not use
an existentially quantified List instead?

Also, and more importantly, when is it necessary to fully apply type
parameters to a function template? And when is it OK to omit them?

Hi Hongwei,

I think this is a brilliant feature. I feel it would be even nicer to pass
the needed templates explicitly as arguments; may be <<.>>. Otherwise the
search strategy reminds me of metaCLOS!

Best.

–shiv–On Sunday, March 8, 2015 at 11:06:57 AM UTC-7, gmhwxi wrote:

I added a chapter on function templates in my Intro-to-ATS book:

Introduction to Programming in ATS

This chapter is in Part V of the book, and it is still being worked.
However, it can
already provide a lot of useful information on function templates in ATS.
Cheers!

Thanks!

Putting the current design of templates into ATS2 was a big gamble on my
part.
I now do feel a lot of comfortable about the design than I did two years
ago, when the
design was largely untested. Before that, I spent at least 3 years trying
to figure out
how to support OOP in ATS2, which led to a design I eventually abandoned
due to its
immense complexity. But I would still like to have some form of OOP :slight_smile:

To properly indicate which template parameters must be provided is
challenging. I will
study the issue more.On Friday, March 13, 2015 at 9:55:31 AM UTC-4, Shivkumar Chandrasekaran wrote:

Hi Hongwei,

I think this is a brilliant feature. I feel it would be even nicer to pass
the needed templates explicitly as arguments; may be <<.>>. Otherwise the
search strategy reminds me of metaCLOS!

Best.

–shiv–

On Sunday, March 8, 2015 at 11:06:57 AM UTC-7, gmhwxi wrote:

I added a chapter on function templates in my Intro-to-ATS book:

Introduction to Programming in ATS

This chapter is in Part V of the book, and it is still being worked.
However, it can
already provide a lot of useful information on function templates in ATS.
Cheers!

The template parameters of a template implementation were not allowed to
be quantifed types. After thinking over the issue today, I slightly
modified the
method used to locate the template implementation for a template instance.
Now you can do

implement(a)
myprint<List(a)> (xs) = …

val () = myprint<List(int)> (…)

Because locating the template implementation for a template instance is done
after the erasure of type indices, the template parameter matching must
be exact.
For instance,

implement(a)
myprint<list(a,2)> (xs) = …

val () = myprint<list(int, 1+1)> (…)

There is NO match here because 1+1 and 2 are syntactically different.On Tuesday, March 10, 2015 at 10:26:04 AM UTC-4, Artyom Shalkhakov wrote:

On Monday, March 9, 2015 at 12:06:57 AM UTC+6, gmhwxi wrote:

I added a chapter on function templates in my Intro-to-ATS book:

Introduction to Programming in ATS

This chapter is in Part V of the book, and it is still being worked.
However, it can
already provide a lot of useful information on function templates in ATS.
Cheers!

Great work!

I have a question: why do you use list0 in the myprint example? Why not
use an existentially quantified List instead?

Also, and more importantly, when is it necessary to fully apply type
parameters to a function template? And when is it OK to omit them?

Very cool! One question: If templates follow a first-fit model, why do you define the specialization partial order? Is it used for anything?> On Mar 8, 2015, at 2:06 PM, gmhwxi gmh...@gmail.com wrote:

I added a chapter on function templates in my Intro-to-ATS book:

Introduction to Programming in ATS

This chapter is in Part V of the book, and it is still being worked. However, it can
already provide a lot of useful information on function templates in ATS. Cheers!


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 mailto:ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com mailto:ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/85e05133-4905-40e9-90af-8a2a4b57d05a%40googlegroups.com https://groups.google.com/d/msgid/ats-lang-users/85e05133-4905-40e9-90af-8a2a4b57d05a%40googlegroups.com?utm_medium=email&utm_source=footer.

The partial order is a concept.
It just happens that it is not used in the current implementation.

It could be useful if one wants to report a warning in a case where
first-fit is not the same as best-fit.On Tuesday, March 10, 2015 at 10:50:13 AM UTC-4, Shea Levy wrote:

Very cool! One question: If templates follow a first-fit model, why do you
define the specialization partial order? Is it used for anything?

On Mar 8, 2015, at 2:06 PM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

I added a chapter on function templates in my Intro-to-ATS book:

Introduction to Programming in ATS

This chapter is in Part V of the book, and it is still being worked.
However, it can
already provide a lot of useful information on function templates in ATS.
Cheers!


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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/85e05133-4905-40e9-90af-8a2a4b57d05a%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/85e05133-4905-40e9-90af-8a2a4b57d05a%40googlegroups.com?utm_medium=email&utm_source=footer
.