Yes. A single scope is worth the hassle. I love not having to care whether
I'm dealing with URL or Form variables. With the attributes scope, I don't
have to care where the variable come from.
---
Jeffrey B. Marsh
Professionals built the Titanic.
Amateurs built the Ark.
-----Original Message-----
From: Hal Helms [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 22, 2001 8:13 PM
To: Fusebox
Subject: RE: Musings on Attributes (was Best Pracices...)
Why have a separate scope at all? What's wrong with just using the URL and
form variables as is? That's what I haven't decided on--is having a single
scope worth the hassle?
Hal Helms
Team Allaire
[ See www.halhelms.com <http://www.halhelms.com> for info on training
classes ]
-----Original Message-----
From: Jeff Peters [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 22, 2001 11:03 PM
To: Fusebox
Subject: Musings on Attributes (was Best Pracices...)
Well, after a small bit of tinkering, here are some thoughts:
First, the processing overhead of FormURL2Attributes isn't huge at all. I
created a variable with 80,000 characters in it, and the difference between
processing the page with and without FormURL2Attributes was a grand 2ms.
OTOH, there is the issue of memory on the server, and doing little
experiments
like this does tend to clog that bottleneck. So, I tried this little gem:
------------------- Vars2FBVars.cfm ----------------------
<cfset FBVars = form>
<cfloop collection="#url#" item="var">
<cfset foo = StructInsert(FBVars,var,Evaluate('url.' & var))>
</cfloop>
---------------- End Vars2FBVars.cfm ---------------------
Those who have been bitten by it will remember what happens when you assign
a
variable the contents of a structure, as in line 1: you get pointers
instead
of a copy of the data. It's irritating if you don't want it to happen, but
perfect for what we want here: to change the referent structure without the
overhead of copying the data.
Unfortunately, there's no way (that I've found yet anyway) to make pointers
for
two structures and combine the two structures into one, so we have to make a
copy of the url structure's pairs into the FBVars structure, as in the loop.
This is an acceptable compromise due to the limited nature of a URL--you'll
never get 80,000-character values in there, now will you?
So we end up with a structure, FBVars, that does what Hal wants (combines
all
the url and form variables in a single structure which you can loop over,
and
isn't a fake copy of the attributes scope). The only question left in my
mind
is whether it's worth bringing in genuine attribute-scoped variables as
well.
The only case where you would need this is if you were going to call the app
as
a custom tag, and I think we're finding that case to be quite uncommon.
Thoughts? What say you, Hal?
- Jeff
[EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists