A partial template application literal syntax

Timon Gehr timon.gehr at gmx.ch
Mon Sep 17 07:43:35 PDT 2012


On 09/17/2012 03:53 PM, bearophile wrote:
>  From this long Reddit post:
> http://www.reddit.com/r/haskell/comments/zxcks/haskell_vs_f_vs_scala_a_highlevel_language/c68ybn1
>
>
> I have seen this linked page:
> https://github.com/non/kind-projector
>
> Where it introduces a (fragile) Scala syntax like:
> Tuple3[Int, ?, ?]
>

Eiffel uses this for partial method application.
http://archive.eiffel.com/doc/online/eiffel50/intro/language/tutorial-12.html

> That is similar to this D, but it's usable in-place:
> template IntFirst3(T2, T3) { alias Tuple!(int, T2, T3) IntFirst3; }
>
> A comparable hypothetical D syntax, for partial template application:
> Tuple!(int, ?, ?)
>
> Being it usable in-place, you can use it as:
>
> static asssert(is(Tuple!(int, ?, ?)!(double, float) ==
>                    Tuple!(int, double, float)));
>

You cannot because multiple ! arguments are disallowed.

Parentheses do not help either because DMDs parser will interpret it as 
a deprecated C-style cast expression. (unless this is removed, the
claim that binary '!' makes parsing non-ambiguous is a myth.)

> It's a fun syntax: Foo!?
>
> Bye,
> bearophile



More information about the Digitalmars-d mailing list