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!
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
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 func
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 alia
On 09/11/2015 02:41 AM, Bahman Movaqar wrote:
> On Friday, 11 September 2015 at 06:14:18 UTC, Ali Çehreli wrote:
>> partial takes the function arguments as 'value template parameters'.
>> Unfortunately, a function pointer like &isEven cannot be 'value
>> template parameters'; only fundamental type
On Friday, 11 September 2015 at 06:14:18 UTC, Ali Çehreli wrote:
On 09/06/2015 12:05 PM, Bahman Movaqar wrote:
> alias bool function(int n) validator_t;
There is the relatively newer alias syntax which is more
intuitive:
alias Validator = bool function(int n);
Great. This is easily re
On 09/06/2015 12:05 PM, Bahman Movaqar wrote:
> alias bool function(int n) validator_t;
There is the relatively newer alias syntax which is more intuitive:
alias Validator = bool function(int n);
> bool isEven(int n) { ... }
> bool isPrime(int n) { ... }
> /**
> * keep
On Monday, 7 September 2015 at 03:55:01 UTC, Meta wrote:
The name validator_t is not idiomatic in D. Something like
ValidatorFun should be preferred. Same for intReader_t;
ReadIntFun is probably preferred, or even IntReader (but that
would imply that it's a struct/class in my mind).
Noted. Th
The name validator_t is not idiomatic in D. Something like
ValidatorFun should be preferred. Same for intReader_t;
ReadIntFun is probably preferred, or even IntReader (but that
would imply that it's a struct/class in my mind).
As for the actual use of partial, it's perfectly fine and
idiomati
Now its clearer to me. You want delegates
http://wiki.dlang.org/Function_literals
On Sunday, 6 September 2015 at 19:22:41 UTC, welkam wrote:
I dont know much about functional programming, but what stops
you defining
int readInt(string prompt, validator_t validator) { ... }
as a free standing function and just call it from both parts of
your code? What is the benefit of ind
I dont know much about functional programming, but what stops you
defining
int readInt(string prompt, validator_t validator) { ... }
as a free standing function and just call it from both parts of
your code? What is the benefit of indirection that you create
when passing function pointer?
I'm just learning D, so please bear with me if I'm asking
something naive.
Consider the following code skeleton:
// in part A of the application...
//
-
alias bool function(int n) validator_t;
bool isEven(int n) { ...
13 matches
Mail list logo