Indeed, this is also another solution, probably the best one right now!

Benoit Hediard

-----Message d'origine-----
De : Gaulin, Mark [mailto:[EMAIL PROTECTED]]
Envoyé : vendredi 27 septembre 2002 21:24
À : CF-Talk
Objet : RE: So many problems with CFC scopes...


Why not put the "not IsDefined()" test right inside any udf library that can
potentially be included more than one time?  (Just put the body of the udf
inside the CFIF block.)

This is like the old "#ifndef _MYFILE_H_", "#define _MYFILE_H_" style that
is used all the time in C and C++ programming.
        Mark

-----Original Message-----
From: Benoit Hediard [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 27, 2002 2:43 PM
To: CF-Talk
Subject: RE: So many problems with CFC scopes...


>> I'm going to look the other issues up in the bugbase in the next few
>> days and see what's there but I'll address these issues here...

Thanks Sean, you're the best.

>>> WORKAROUND : use the <cfif isDefined("oneOfTheFunctionName")><cfinclude
>>> template="myUDFlib.cfm"></cfif> in the CFC to test if the UDF lib has
>>> already be included.

>>Yes, that is what we do here. It also encourages you to have one
>>function per include file...

If we have to implement manually <cfif isDefined("function")> each time we
want to include a UDF lib, I was wondering why this is not automatically
done by CF. If the function is already defined and the new definition is
identical to the first one, CF might ignore the second definition instead of
throwing an error.
It would save us a lot of work and possible errors (if someone forget the
<cfif isDefined("")>).

I agree that CF should throw an error if the method definition is different
(defined in another template lib than the previous one), but not if the
method definition is identical (defined in the same template lib than the
previous one).
Is it impossible to implement?

With complex CFCs, I personally find that it is much cleaner and easier to
only define
the necessary UDF lib inside each included CFC method files
instead of
all the necessary UDF lib at the top of the CFC (especially if you use one
function per include file with <cfif isDefined()> around each).

>> What if the file changes during the processing of the request?

Would it give problems?
If the template is changed during the processing of the request, the new
function definition would be ignored (defined in the same template than the
previous one), isn't it?


I agree that the <cfif isDefined("")> is OK, but I am just curious to know
if the UDF lib include behaviour could be improved.


Benoit Hediard

-----Message d'origine-----
De : Sean A Corfield [mailto:[EMAIL PROTECTED]]
Envoyé : vendredi 27 septembre 2002 19:39
À : CF-Talk
Objet : Re: So many problems with CFC scopes...


I'm going to look the other issues up in the bugbase in the next few
days and see what's there but I'll address these issues here...

On Friday, Sep 27, 2002, at 02:36 US/Pacific, Benoit Hediard wrote:
> - CFC methods defined in an included file cannot really include UDF
> lib.
> Indeed, CF refuses to include twice the same UDF lib in one single
> script,
> which could be the case with two CFC included methods definition that
> use
> the same UDF lib.

Because you cannot have more than one definition of a function - which
is what happens when you include the UDF multiple times. You can't do
this in most other languages (define the same function twice) so I
don't know why you'd expect it to work in CF.

> - UDF lib cannot be included in a CFC if the UDF lib is already
> included in
> the script calling the CFC.

This is essentially the same problem as above.

> WORKAROUND : use the <cfif isDefined("oneOfTheFunctionName")><cfinclude
> template="myUDFlib.cfm"></cfif> in the CFC to test if the UDF lib has
> already be included.

Yes, that is what we do here. It also encourages you to have one
function per include file...

> I wonder if it could be possible that CF accept to include several
> times the
> same UDF lib : if it is the same file, it should not complain about it.

What if the file changes during the processing of the request?

"I have always wished that my computer would be as easy to use as my
telephone.
  My wish has come true - I no longer know how to use my telephone."
-- Bjarne Stroustrup




______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to