www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - popFront with input variables

reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
Hello all,

Is it considered legit in any circumstances for popFront to take an input 
variable (e.g. a random number generator)?  Or is it required always to have no 
input variables?

Thanks & best wishes,

     -- Joe
Aug 31 2012
parent "bearophile" <bearophileHUGS lycos.com> writes:
Joseph Rushton Wakeling:

 Is it considered legit in any circumstances for popFront to 
 take an input variable (e.g. a random number generator)?  Or is 
 it required always to have no input variables?
popFront is meant to be called by foreach, or to be verified by the isSomething compile-time tests of std.range. In both cases if popFront takes an argument, it doesn't work. So I think it's not a good idea. struct Foo { enum bool empty = false; property int front() { return 1; } void popFront(int x) {} //void popFront() {} } void main() { import std.stdio; foreach (i; Foo()) writeln(i); } temp.d(9): Error: function temp.Foo.popFront (int x) is not callable using argument types () temp.d(9): Error: expected 1 function arguments, not 0 Bye, bearophile
Aug 31 2012