September 11, 2015 Re: How To: Passing curried functions around | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Bahman Movaqar | On 09/11/2015 01:07 PM, Bahman Movaqar wrote:
> On Friday, 11 September 2015 at 18:39:15 UTC, Ali Çehreli wrote:
>> >> import std.stdio;
>> >>
>> >> bool isEven(int n) {
>> >> return !(n % 2);
>> >> }
>> >>
>> >> int readValidInt(alias validator)(string prompt) {
>>
>> readValidInt() is a function template that takes two information:
>>
>> 1) The validator as its alias template parameter. alias template
>> parameter allows it to work with anything that can be called.
>
> I read "alias and with" chapter of the book to understand this but
> couldn't find any such use for `alias` there. Does using `alias`
> instead of a type makes the parameter a `callable`?
Sorry for the confusion. :) The same keyword has a different use with templates:
http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.alias,%20template%20parameter
Ali
| |||
September 11, 2015 Re: How To: Passing curried functions around | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On 09/11/2015 02:04 PM, Ali Çehreli wrote: > The same keyword has a different use with > templates: And the official documentation: http://dlang.org/template.html#TemplateAliasParameter Ali | |||
September 12, 2015 Re: How To: Passing curried functions around | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Friday, 11 September 2015 at 21:06:32 UTC, Ali Çehreli wrote:
> On 09/11/2015 02:04 PM, Ali Çehreli wrote:
>> The same keyword has a different use with
>> templates:
>
> And the official documentation:
>
> http://dlang.org/template.html#TemplateAliasParameter
Thanks again!
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply