www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - .fflush() in stdio.d

reply berni <someone somewhere.com> writes:
Out of curiosity: Browsing the source of stdio.d I found that 
flush() is implemented by calling fflush from some C++ library. 
What I don't understand: Why is the call to fflush preceded by a 
dot?
Aug 25 2019
parent reply Jonathan M Davis <newsgroup.d jmdavisprog.com> writes:
On Sunday, August 25, 2019 11:59:08 PM MDT berni via Digitalmars-d-learn 
wrote:
 Out of curiosity: Browsing the source of stdio.d I found that
 flush() is implemented by calling fflush from some C++ library.
 What I don't understand: Why is the call to fflush preceded by a
 dot?
The dot makes it so that it's specifically referencing a module-level symbol (be it in that module or an imported module) instead of a local or member symbol. https://dlang.org/spec/module.html#module_scope_operators In this particular case, it doesn't look like the dot is necessary, because File doesn't have an fflush member, but there are a number of cases where it has a member that's the same as a C function that it wraps, in which case the dot would be necessary to reference the C function instead of the member function. So, it wouldn't surprise me if whoever wrote that code was just putting a dot in front of C function calls in general. - Jonathan M Davis
Aug 26 2019
next sibling parent a11e99z <black80 bk.ru> writes:
On Monday, 26 August 2019 at 09:14:23 UTC, Jonathan M Davis wrote:
 On Sunday, August 25, 2019 11:59:08 PM MDT berni via

 - Jonathan M Davis
OFFTOPIC: (dont have ur email. dont like emails cuz too officially and too long) (and dont want create new topic. this one probably solved/finished already) about benchmark https://dlang.org/library/std/datetime/stopwatch/benchmark.html idk all reason why that not vice versa but imo better to change: for now: Duration[3] benchmark!(f1, f2, f3)( int runCount ); remarks:
 benchmark!(
         // next is simple func list
 	() => ps.each!( p => b += gcd( p[0], p[1])),
 	() => ps.each!( p => a += divGCD( p[0], p[1])),

 )( 10 ) // and here real call with complicated number

 	.array // without it .map! is not compiling
 	.map!( x => x.total!"msecs")
 	.writeln;
1) .map! for static arrays doesn't compiling maybe better to return Range? 2) code with benchmark!() looks turn upside down when u try to use lambdas as args I suggest add another versions of benchmark: auto bench!( int N, FuncList...)( FuncList funcs );
 benchmark!10( () => ps.each!( p => b += gcd( p[0], p[1])),
 	      () => ps.each!( p => a += divGCD( p[0], p[1])))...
auto bench!( FuncList...)( int N, FuncList funcs );
 benchmark( 10,
 	() => ps.each!( p => b += gcd( p[0], p[1])),
 	() => ps.each!( p => a += divGCD( p[0], p[1])))...
Aug 26 2019
prev sibling parent berni <someone somewhere.com> writes:
On Monday, 26 August 2019 at 09:14:23 UTC, Jonathan M Davis wrote:
 The dot makes it so that it's specifically referencing a 
 module-level symbol (be it in that module or an imported 
 module) instead of a local or member symbol.
Ah, thanks. Now it makes sense! :)
Aug 26 2019