Use cases for alias parameters

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Tue Nov 13 12:34:27 PST 2007


Bruno Medeiros wrote:

> I was reading the discussion at
> http://d.puremagic.com/issues/show_bug.cgi?id=1100 , and then it got me
> thinking:
> 
> What are the use cases for alias parameters, other than:
> * parameters that are templates
> * parameters that are variables
> ?
> 
> In particular is there any meaningful use case for:
> * parameters that are either variables or types ?

You can do all kinds of stuff with types, for example foldr/l, currying,
filter, map etc. These are pretty awesome features in my opinion.

I'm still hoping we could somehow unify the templates and proposed macros in
some way. The undocumented feature Chris mentioned is pretty interesting
indeed:

template foo(alias bar) {
  ...
}

void moose() {
  foo!({ chicken(); });
  ...
}

Since alias accepts only explicitly defined symbols and for some unknown
reason delegate literals, I thought this was a hidden macro system :) It
could possibly inline the delegate but it doesn't currently :| Also there
are interesting places where alias parameters could be used, e.g. operator
overloadings (to avoid extra parameter passing). Extending these could
eliminate many cases where you need to use ugly CTFE&mixin trick.



More information about the Digitalmars-d mailing list