[Issue 9437] New: unwanted behavior from phobos range
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 1 04:57:48 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9437
Summary: unwanted behavior from phobos range
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bioinfornatics at gmail.com
--- Comment #0 from bioinfornatics <bioinfornatics at gmail.com> 2013-02-01 04:57:46 PST ---
Dear,
Recently i seen that the range used into tje loop is not the same instance as
this one created. the followed code show the problem
-------------------------------------------------
import std.stdio;
struct R{
private:
size_t _position;
string _word;
public:
this( string word ){
_word = word;
}
@property size_t length () const {
return _word.length;
}
@property bool empty() const{
return ( _position >= _word.length );
}
char front() const {
return _word[ _position ];
}
void popFront(){
_position++;
}
ubyte toUbyte() const {
return cast(ubyte) _word[_position] ;
}
alias length opDollar;
}
void main( string[] args ){
R r = R( "Hello D users" );
foreach( l; r )
writeln( l, ", ", r.front() );
}
-------------------------------------------------
his output:
-------------------------------------------------
./tesRange
H, H
e, H
l, H
l, H
o, H
, H
D, H
, H
u, H
s, H
e, H
r, H
s, H
-------------------------------------------------
The problem:
- it seem is do a copy so when you create a range over a mmfile it will mapped
the file more than once while when we use mmfile we want some perf
- we are not able to implement some method to give the current state wile is
looping. For this you should return all possible value that you could be used
in popFront() !!!
If someone know how to querry the instance used to loop i am aware
thank
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list