Also, UFCS makes no sense on overloaded operators, because they
don't get
called with ., and all UFCS is is changing obj.func(params)
to func(obj,
params).
- Jonathan M Davis
Ok, that's basically what I was wondering. I had assumed
foreach(e; someThing) {} could possibly have been converted
On 07/18/2012 08:21 AM, Mike L. wrote:
Also, UFCS makes no sense on overloaded operators, because they
don't get
called with ., and all UFCS is is changing obj.func(params) to
func(obj,
params).
- Jonathan M Davis
Ok, that's basically what I was wondering. I had assumed foreach(e;
How exactly does the compiler know how to do foreach on ranges
(for example, ones returned by std.algorithm.map ?) I've looked
around in std.algorithm and std.range, but can't seem to figure
it out.
On 07/17/2012 11:59 AM, Mike L. wrote:
How exactly does the compiler know how to do foreach on ranges (for
example, ones returned by std.algorithm.map ?) I've looked around in
std.algorithm and std.range, but can't seem to figure it out.
The spec mentions it under 'Foreach over Structs
On Tuesday, July 17, 2012 20:59:12 Mike L. wrote:
How exactly does the compiler know how to do foreach on ranges
(for example, ones returned by std.algorithm.map ?) I've looked
around in std.algorithm and std.range, but can't seem to figure
it out.
It translates
foreach(e; range
On Tuesday, 17 July 2012 at 19:27:54 UTC, Jonathan M Davis wrote:
It translates
foreach(e; range)
{}
into something like
foreach(auto __range = range; !__range.empty;
__range.popFront())
{
auto e = __range.front;
}
The compiler knows just enough about ranges to enable foreach
;
}
The compiler knows just enough about ranges to enable foreach,
but beyond
that, ranges are entirely a library construct.
The spec' says If the foreach range properties do not exist, the
opApply method will be used instead., does this mean that range
properties take precedence over
On Tuesday, 17 July 2012 at 19:45:45 UTC, Jonathan M Davis wrote:
This post gives the current precedence, but there was some
discussion of
adjusting it a bit:
http://forum.dlang.org/post/mailman.275.1342019430.31962.digitalmars-
d...@puremagic.com
From the looks of it, opApply gets
Çehreli wrote:
On 07/17/2012 11:59 AM, Mike L. wrote:
How exactly does the compiler know how to do foreach on ranges
(for
example, ones returned by std.algorithm.map ?) I've looked
around in
std.algorithm and std.range, but can't seem to figure it out.
The spec mentions it under 'Foreach over
On Wednesday, July 18, 2012 06:27:28 Mike L. wrote:
Thanks for the reply. Not sure how I missed it there. Interesting
that the compiler has to be made aware of a concept that I had
thought was only supposed to be part of phobos. Would it be
possible to implement it in std.range using the new
On Wednesday, 18 July 2012 at 04:54:51 UTC, Jonathan M Davis
wrote:
On Wednesday, July 18, 2012 06:27:28 Mike L. wrote:
Thanks for the reply. Not sure how I missed it there.
Interesting
that the compiler has to be made aware of a concept that I had
thought was only supposed to be part of
On Wednesday, July 18, 2012 07:19:59 Kapps wrote:
If UFCS worked on operators, you would be able to make ranges
without any compiler support.
int opApply(T)(T Range) if(isInputRange!T) {
// Stuff.
}
You can't overload operators externally to a user-defined type. They must be
part of
Is that not implemented yet?
TDPL mentions a very useful feature on page 381 under 12.9.1 foreach
with Iteration Primitives.
(Note: I am copying all of this manually; the typos are mine):
It first shows a function that includes a possible compiler rewrite of
a foreach loop:
void
Ali Çehreli Wrote:
quote
... if the iterated object offers the slice operator with no arguments
lst[], __c is initialized with lst[] instead of lst. This is in order to
allow extracting the iteration means out of a container without
requiring the container to define the three iteration
On 02/17/2011 01:49 PM, Jesse Phillips wrote:
Ali �ehreli Wrote:
quote
... if the iterated object offers the slice operator with no arguments
lst[], __c is initialized with lst[] instead of lst. This is in order to
allow extracting the iteration means out of a container without
requiring the
15 matches
Mail list logo