It doesn't return an "instance", it returns a reference:

<cffunction name="testfunc">
    <cfreturn testfunc />
</cffunction>

<cfset x = testfunc()>

<cfif testfunc.equals(x)>
    reference
<cfelse>
    copy
</cfif>


Tim.


-------------------------------------------------------
RAWNET LTD - Internet, New Media and ebusiness Gurus.
Visit our new website at http://www.rawnet.com for
more information about our company, or call us free
anytime on 0800 294 24 24.
-------------------------------------------------------
Tim Blair
Web Application Engineer, Rawnet Limited
Direct Phone : +44 (0) 1344 393 441
Switchboard : +44 (0) 1344 393 040
-------------------------------------------------------
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
-------------------------------------------------------


> -----Original Message-----
> From: Raymond Camden [mailto:[EMAIL PROTECTED] 
> Sent: 20 August 2003 03:55
> To: CF-Talk
> Subject: RE: Uniquely identifying a function
> 
> 
> Answer my own question. It returns an instance of itself. So 
> you could do, 
> 
> x = foobar();
> y = x();
> 
> Not that you would want to, though. :)
> 
> ==============================================================
> ==========
> ===
> Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
> (www.mindseye.com)
> Member of Team Macromedia 
> (http://www.macromedia.com/go/teammacromedia)
> 
> Email    : [EMAIL PROTECTED]
> Blog     : www.camdenfamily.com/morpheus/blog
> Yahoo IM : morpheus
> 
> "My ally is the Force, and a powerful ally it is." - Yoda 
> 
> > -----Original Message-----
> > From: Raymond Camden [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, August 19, 2003 8:07 PM
> > To: CF-Talk
> > Subject: RE: Uniquely identifying a function
> > 
> > 
> > Interesting tip - even more so - interesting function. Your
> > UDF returns the UDF - what happens if you call it? :)
> > 
> > ==============================================================
> > ==========
> > ===
> > Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
> > (www.mindseye.com)
> > Member of Team Macromedia
> > (http://www.macromedia.com/go/teammacromedia)
> > 
> > Email    : [EMAIL PROTECTED]
> > Blog     : www.camdenfamily.com/morpheus/blog
> > Yahoo IM : morpheus
> > 
> > "My ally is the Force, and a powerful ally it is." - Yoda
> > 
> > > -----Original Message-----
> > > From: Matt Liotta [mailto:[EMAIL PROTECTED]
> > > Sent: Tuesday, August 19, 2003 7:54 PM
> > > To: CF-Talk
> > > Subject: Re: Uniquely identifying a function
> > > 
> > > 
> > > BTW, you can get the name of the CFM that the function is 
> defined in 
> > > by calling the getPagePath() method of the function. See the 
> > > following example.
> > > 
> > > <cffunction name="foobar">
> > >   <cfreturn foobar>
> > > </cffunction>
> > > <cfdump var="#foobar.getPagePath()#">
> > > 
> > > -Matt
> > > 
> > > On Tuesday, August 19, 2003, at 06:49 PM, Tim Blair wrote:
> > > 
> > > >> Obviously, your function names must be unique per CFM, so
> > > the unique
> > > >> name for all functions is a concatenation of the CFM 
> name and the 
> > > >> function name.
> > > >
> > > > Indeed that is true, the problem comes when I'm trying to
> > work out
> > > > which CFM page contains the function: I'm performing the key
> > > > generation from within the CFC, so it's a bit of a hassle
> > > to work out
> > > > where the function "came from".  Any way, the 
> toString() method I 
> > > > provided initially basically does what you have stated,
> > in a round
> > > > about kind of way.
> > > >
> > > >> Here is a quick UDF (read not tested) that does what you
> > need. ...
> > > >>                return theName.hashCode();
> > > >
> > > > That's not going to identify a function uniquely - the 
> hashCode()
> > > > method will return the hashcode for the theName variable,
> > > not for the
> > > > function.  If I called the method again with exactly the
> > > same value,
> > > > it'd return a different hashcode.
> > > >
> > > > Saying that however, using hashCode() against the
> > function directly
> > > > _will_ work and also saves on the hash() call.  I can
> > > replace the key
> > > > generation line:
> > > >
> > > > <cfset key = this.KEYPREFIX & hash(myFuncRef.toString())>
> > > >
> > > > with the following, removing one method call per generation
> > > (not much,
> > > > but I'm sure they'll all add up, especially as it's a
> > > crypto function
> > > > call I'm removing) and guaranteeing the key is unique (and
> > > always the
> > > > same) for that function:
> > > >
> > > > <cfset key = this.KEYPREFIX & myFuncRef.hashCode())>
> > > >
> > > > For those that are wondering, the hashCode() method is a
> > java method
> > > > implemented in the base Object class that all other
> > classes extend
> > > > from by default.  By definition it is guaranteed to
> > return a unique
> > > > (integer) ID for each object and if the function is called
> > > on the same
> > > > object more than once during the lifetime of the Java 
> application 
> > > > (i.e. CFMX), the same hash code will be returned on each call.
> > > > Generally, the unique ID is generated from the internal 
> > > memory address
> > > > of the given object.
> > > >
> > > > Additionally, the key generated by the hashCode() method is much
> > > > shorter than using a hash(toString()) representation (8 
> > or so bytes
> > > > compared to 32) so storing the key in memory won't eat up
> > > so much RAM.
> > > >  Not exactly the biggest gain in the world but sometimes
> > every byte
> > > > counts...  ;)
> > > >
> > > > Cheers for the pointer Matt, even if it wasn't exactly what you
> > > > meant...  ;)
> > > >
> > > >> You might also be interested in the following Java class
> > > >
> > > > That's cool, but surely the toString() method I stated returns
> > > > (basically) this info anyway, but it is more relevant for
> > the use I
> > > > need because it also includes the sub-class for the function
> > > > reference.  Ta anyway - may well come in useful at some point!
> > > >
> > > > The question still remains, is this a sensible way to go?
> >  No one's
> > > > come down on me like a ton of bricks so I'm guessing it's OK...
> > > >
> > > > Tim.
> > > >
> > > > -------------------------------------------------------
> > > > RAWNET LTD - Internet, New Media and ebusiness Gurus. Visit our 
> > > > new website at http://www.rawnet.com for more information about 
> > > > our company, or call us free anytime on 0800 294 24 24.
> > > > -------------------------------------------------------
> > > > Tim Blair
> > > > Web Application Engineer, Rawnet Limited
> > > > Direct Phone : +44 (0) 1344 393 441
> > > > Switchboard : +44 (0) 1344 393 040
> > > > -------------------------------------------------------
> > > > This message may contain information which is legally privileged
> > > > and/or confidential. If you are not the intended 
> > recipient, you are
> > > > hereby notified that any unauthorised disclosure, copying,
> > > > distribution or use of this information is strictly 
> > prohibited. Such
> > > > notification notwithstanding, any comments, opinions, 
> information 
> > > > or conclusions expressed in this message are those of the 
> > > > originator, not of rawnet limited, unless otherwise 
> explicitly and 
> > > > independently indicated by an authorised representative 
> of rawnet 
> > > > limited.
> > > > -------------------------------------------------------
> > > > 
> > > 
> > 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

Reply via email to