Function template syntax: a tiny question

19 views
Skip to first unread message

Yannick Duchêne

unread,
Feb 2, 2015, 3:23:18 PM2/2/15
to ats-lan...@googlegroups.com
One may write “fun {a:t@ype}{b:t@ype} f” or “fun {a,b:t@ype} f”. My guess is that the only difference between these two syntaxes, is about the use of “{..}”: is that it? And that it does not make a difference with regard to “{...}”?

I'm actually reviewing INT2PROGINATS a second time, that's how this question came to me.

gmhwxi

unread,
Feb 2, 2015, 4:05:14 PM2/2/15
to ats-lan...@googlegroups.com
The difference lies in the way in which template arguments
are provided:

fun
{a:t0p}
{b:t0p}
foo (x: a, y: b) = (x, y)
val _ = foo (0, "1")
val _ = foo<int><string> (0, "1")

fun
{a,b:t0p}
foo2 (x: a, y: b) = (x, y)
val _ = foo2 (0, "1")
val _ = foo2<int,string> (0, "1")

Currently, template arguments need to be all supplied or all omitted.

Yannick Duchêne

unread,
Feb 2, 2015, 4:21:43 PM2/2/15
to ats-lan...@googlegroups.com


Le lundi 2 février 2015 22:05:14 UTC+1, gmhwxi a écrit :
Currently, template arguments need to be all supplied or all omitted.

So “{..}” is only for parametric polymorphism?

Hongwei Xi

unread,
Feb 2, 2015, 4:25:17 PM2/2/15
to ats-lan...@googlegroups.com
Yes.

It is plausible to support something like the following in the future:

foo<..><string>, foo<...>, foo2<_,string>

--
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/8b4d1781-44ee-40f7-8119-1f34af8104b7%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages