Hello Jonathan,
For example, there are two functions that I'd like to be have: all()
and any(). That is, I want a function which checks a predicate against
a range and returns whether all elements in that range satisfy the
predicate, and I want a function that checks a predicate against a
range
On Sun, Jun 27, 2010 at 08:07, BCS n...@anon.com wrote:
Hello Jonathan,
For example, there are two functions that I'd like to be have: all()
and any(). That is, I want a function which checks a predicate against
a range and returns whether all elements in that range satisfy the
predicate,
auto fn1 = ( string s ) {
return s;
};
auto fn2 = ( string s ) {
return map!fn1( [] );
};
auto idirs = map!fn2( [] );
The above code gives the following errors:
foo.d(114): Error: struct foo.main.Map!(fn2,string[]).Map inner struct
Map cannot be a field
foo.d(114): Error:
Hi all,
The D2.0 lexical page describes delimited string and token string
literals. Is there any example of how these are used and why, somewhere?
Thanks
-- Pierre
Pierre Rouleau prouleau...@gmail.com wrote:
Hi all,
The D2.0 lexical page describes delimited string and token string
literals. Is there any example of how these are used and why, somewhere?
Token strings are added for the specific use case of string mixins[1].
They must contain valid D
On Sun, Jun 27, 2010 at 10:11, Simen kjaeraas simen.kja...@gmail.comwrote:
auto fn1 = ( string s ) {
return s;
};
auto fn2 = ( string s ) {
return map!fn1( [] );
};
auto idirs = map!fn2( [] );
The above code gives the following errors:
foo.d(114): Error: struct
On 27/06/10 9:52 AM, Simen kjaeraas wrote:
Pierre Rouleau prouleau...@gmail.com wrote:
Hi all,
The D2.0 lexical page describes delimited string and token string
literals. Is there any example of how these are used and why, somewhere?
Token strings are added for the specific use case of
Is it defined somewhere that auto functions are not authorized inside main?
void main()
{
auto fun(string s) { return s;} // this does not compile
}
error:
main.d|6|found 's' when expecting ')'|
main.d|6|semicolon expected, not ')'|
main.d|6|found ')' instead of statement|
Pierre Rouleau:
I was wondering if D had the equivalnt of Python's triple quote string
literals and it does: the delimited string serves the same purpose. Great!
But keep in mind that normal D string literals can span more than one line :-)
Bye,
bearophile
Philippe Sigaud:
I couldn't find a bugzilla entry for this and I cannot believe no one ever
tried to put an auto fun inside main!
Maybe auto funcs are seen as instantiated templates, and templates can't be
defined inside functions. Anyway, I think you can file this as enhancement
request.
Jonathan M Davis:
Okay. The functions in std.algorithm are quite powerful, but sometimes you
have
to play around with them a bit to figure out how to do exactly what you're
trying
to do.
Some of them need to be improved in their concept and API. Some of them are
awkward to use or they
On 27/06/10 11:36 AM, bearophile wrote:
But keep in mind that normal D string literals can span more than one line :-)
In what sense? In the sense that adjacent strings are concatenated? If I
want to create a string literal that embeds new line without explicitly
placing a '\n' inside the
Why doesn't the following code work in D2 (it works in D1)?
void foo (T) (in T[] a, T b)
{
}
void main ()
{
asd.foo('s');
}
The error I get is:
main.d(10): Error: template main.foo(T) does not match any function
template declaration
main.d(10): Error: template main.foo(T)
On 06/27/2010 12:18 PM, Jacob Carlborg wrote:
Why doesn't the following code work in D2 (it works in D1)?
void foo (T) (in T[] a, T b)
{
}
void main ()
{
asd.foo('s');
}
asd.foo(cast(immutable) 's');
Jacob Carlborg d...@me.com wrote:
Why doesn't the following code work in D2 (it works in D1)?
void foo (T) (in T[] a, T b)
{
}
void main ()
{
asd.foo('s');
}
The error I get is:
main.d(10): Error: template main.foo(T) does not match any function
template declaration
On 2010-06-27 19:26, Simen kjaeraas wrote:
Jacob Carlborg d...@me.com wrote:
Why doesn't the following code work in D2 (it works in D1)?
void foo (T) (in T[] a, T b)
{
}
void main ()
{
asd.foo('s');
}
The error I get is:
main.d(10): Error: template main.foo(T) does not match any function
Hello Jacob,
That's annoying, specially since char is a value type. I would
preferably have a solution for both D1 and D2. Can I use a template to
cast/alias away the immutable part?
One solution would be to have templates strip off const/immutable from the
top level of args.
void F1(T)(T
Hi list,
I tried to write a traits class comparable to iterator_traits in C++ STL
or graph_traits in Boost Graph Library in D 2.0, but failed to do so via
template specialization which is put into different modules. Putting
everything into one module interferes with extensibility. I tried the
18 matches
Mail list logo