www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - is there such a thing as a "static" function template that isn't

reply Christopher the Magnificent <ultimatemacfanatic gmail.com> writes:
I see this code AT THE TOP (MODULE) LEVEL of one of Michel Fortin's 
D/Objective-C bridge source files and I'm trying to wrap my head around it.

	/** Wrap an object instance within an object of this class. */
	static Object
	objcCreateWrapper(T)(id instance)
	{
		// Retain the Objective-C instance prior wrapping it.
		// It needs to be done prior wrapping so that
		// invariants holds
		// after the constructor is called.
		objc.msg.send!(id)(instance, selector!("retain"));
		
		// Create new Wrapper.
		return new T(instance);
	}

At issues is the keyword "static" in front of the template function. 
This is not inside of a class, so static does not seem to make sense 
with what I know about D.  Can anyone explain this to me?

--Christopher
Jul 16 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-07-16 23:34, Christopher the Magnificent wrote:
 I see this code AT THE TOP (MODULE) LEVEL of one of Michel Fortin's
 D/Objective-C bridge source files and I'm trying to wrap my head around it.

 /** Wrap an object instance within an object of this class. */
 static Object
 objcCreateWrapper(T)(id instance)
 {
 // Retain the Objective-C instance prior wrapping it.
 // It needs to be done prior wrapping so that
 // invariants holds
 // after the constructor is called.
 objc.msg.send!(id)(instance, selector!("retain"));

 // Create new Wrapper.
 return new T(instance);
 }

 At issues is the keyword "static" in front of the template function.
 This is not inside of a class, so static does not seem to make sense
 with what I know about D. Can anyone explain this to me?

 --Christopher

I'm guessing it has no affect on the code, possible it used to be a static method in a class. -- /Jacob Carlborg
Jul 17 2011