Cold Fusion is weak in these areas, but really you can do all these things (or 
"emulate" them :-) ) using existing features.
(forgive my syntax - I'm writing this quickly)

Pick a standard variable name, like ReturnValue and only use it for returning a value 
from a custom tag:
        caller.ReturnValue = xxx

Or use the tag's name as a structure:
        If NOT IsDefine("MyTagName") {
                MyTagName = StructNew()
                }
        MyTagName.Return = "some data"


Static variables: How static do you want them? :-) Cold Fusion has extra "scopes" that 
wouldn't make sense in a standard programming language like C++ where the application 
all runs at once. In Cold Fusion you might want static variables that retain their 
value (1) for the entire Application, (2) for the page request (there are more you 
could define if you tried hard).
Pick a standard word, for example "static" and keep them under Application and 
Request. Use a hash of the module name:

In Application.cfm:
        If NOT IsDefined('Request.Static')
                Request.Static = StructNew()

In module: MyTagName:
        Request.Static["MyTagName"] = StructNew()
        Request.MyTagName.ThisStaticVar = "some data";

This is now a static variable that will retain it's value for the duration of this 
page request through all files and multiple calls to this tag. It is only "private" 
within the tag because you make it so with the naming convention. The same thing can 
be done under the Application scope (scopes are structures).

Now the *REAL* problem with Cold Fusion is there is no ability to define a macro, 
function, or subroutine to "hide" these details so these kinds of things are very 
wordy which encourages mistakes when you have to specify them a hundred times.

At 02:49 PM 8/28/00 -0400, Jamie Keane wrote:
>My biggest complaint with the language is the lack of user-defined
>functions.  I know that custom tags are sorta a work-around, but sometimes a
>function just needs to return a value, not just assign a value back to the
>calling template.  Also, there's no way (that I know of at least) to pass
>values by reference, or declare static variables within the scope of a
>custom tag.  While PHP doesn't have the simplicity that CF has in terms of
>database twiddling, and its error handling leaves a bit to be desired, it
>does have support for user-defined functions that may contain variable
>references and static variables, and that helps me out a lot.
>
>--
>Jamie Keane
>Programmer
>SolutionMasters, Inc.
>9111 Monroe Rd., Suite 100
>Charlotte, NC  28270
>www.solutionmasters.com
>704.563.5559 x 228  Voice
>704.849.9291  Fax
>-----Original Message-----
>From: Gregory Harris <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
>Date: Monday, August 28, 2000 2:30 PM
>Subject: Re: What I want in CF (was: Learning ASP)
>
>
>Ok, my wish list now:
>
>1) How about a way to determine whether a dimension exists in an array, for
>instance this works:
>
>ArrayLen(ThisArray)
>
>But if ThisArray were a 2 dimensional array and I needed to figure out the
>length of something in dimension 2, using this
>
>ArrayLen(ThisArray[DimensionOne]) breaks the page
>
>Rather than having to go thru the excess overhead of trying to use a
>counter, maybe extending Arraylen could help this? Or how about a
>ArrayDimensionExists() function?
>
>2) Extending CFHTTP (I think this is a BIG one)
>
>3) Making Structures Multi-Dimensional, or is it possible to do structures
>like:
>
>Stuff.Things.MoreThings = ThisVariable
>
>This has never worked with me, the best I could do would be Stuff.Things
>
>I'm sure there are more headaches I've run into, but these are right off the
>top of my head.  What else can everyone think of?
>
>Gregory Harris
>Los Angeles Information Technology Agency (ITA)
>[EMAIL PROTECTED]
>
>
>>>> [EMAIL PROTECTED] 08/28 11:11 AM >>>
>>>> Dave Watts [mailto:[EMAIL PROTECTED]]
>I agree that the interfaces for SMTP, POP, HTTP, etc. need a lot of work. As
>for other stuff, I'm kind of curious. What basic functionality would you
>like to see? I can't really think of all that much that I'd like to see
>added.
><<<
>
>Personally, I've got a laundry list.  :)  However, off the top of my head,
>in no particular order (I mentioned most of these at The Con last year, and
>will do so again if I go this year):
>
>1. Extend the CFX API to make it more useful.  There are some things (like
>working with arrays, as Jeremy mentioned) that don't work or are hellishly
>hard to workaround.  Some of us (very few, I know) *like* to work in C++ and
>*like* to optimize our stuff by putting it in machine code.
>
>2. Fix the encryption.  It's really *really* broken.
>
>3. (or, in deference to or addition to #2) Support for "compiling"
>templates.  We know that they already do this in memory (something akin to a
>p-code or bytecode type thing), but what I'd like to see is the ability to
>take that compiled chunk of memory and save it to a file.  Python has this,
>as does Perl (in a limited sense).  This would do two things for me: (a) It
>would mean that even though people could still "decompile" it, they'd still
>have to figure out var names, etc.  (b) It would save the overhead of
>parsing the file every time.
>
>4. Better regular expression engine.  (Especially non-greedy matching.)
>
>5. Better locking system.  (This is a whine.)  It's all fine and good to put
>the burden of the locking on the programmer (who has to go absolutely crazy
>on the CFLOCKs in a production system), but I'd really like to see something
>a bit better.  I dunno how, but I know they have some pretty smart people
>who can surprise us.
>
>6. Binary data support for variables. (Unicode?)  Right now I can't
>(reliably) mess around with binary files.  :(
>
>7. Fix CFHTTP!  Please!  In the current implementation so much is broken
>it's not even funny!
>a. Not thread-safe (gah!)
>b. Can't use CFHTTPPARAM (and therefore cookies) without the POST method.
>(lame)
>c. Can't select encoding type (multipart/form-data doesn't work
>everywhere) - at least make it smart enough so that if no files are attached
>it doesn't use multipart! (exceedingly lame)
>d. The hack for port is *stupid*.  If I want to access an arbitrary URL that
>could be on any port, I have to manually parse out the port number from the
>URL and put it in the PORT attribute and at the same time take it out of the
>URL string (it barfs otherwise!).  (mired in a sweaty mass of lameness)
>
>8. Fix PreserveSingleQuotes() - Right now it doesn't act like a real
>function.  I can't do other things in it.  That is,
>PreserveSingleQuotes(ListChangeDelims(list,"','")) is broken.  (This is my
>most common use for it.)
>
>9. Fix the standard structures (Form, Client, etc) to actually work like
>structures, so that I can enumerate them, delete from them, etc.  Having to
>GetClientVariables() or get Form.FieldNames is just annoying (and doesn't
>let my code be nice and transparent.)  Did they fix thix in 4.5?  I think
>they are getting closer, but I think it is still broken?
>
>
>Hmmm ... I'm trying to think of all the things I constantly have to hack
>arround ...
>
>. Passing arrays (even scalars) by reference instead of value.
>
>. Accessing structure members in the order they were added, instead of
>having to hack around it with a parallel list/array.  (However, I know how
>hashes work, so this probably wouldn't be worth it.)
>
>. ListSort(list[,type[,order]]) - Hacked around with arrays
>
>. ListEliminateDuplicates(list) - Hacked around with structures (and arrays
>if you need to preserve order)
>
>. ListSlice(list,start,length) && ArraySlice(array,start,length) - or,
>better yet, ListSlice(list,start,length,newlist), so that I can dynamically
>replace the middle of a list (newlist doesn't have to be as long as length,
>tho)
>
>. QuerySetRow(query,"valuelist"[,row]) or QuerySetRow(query,array[,row])
>(preferred)
>
>. QueryDeleteRow(query,row)
>
>. QuerySort(query,column[,type[,order]])
>
>. StructMerge(struct1,struct2) - Iterates over struct2 assigning its keys to
>struct1 (overwriting if necessary)
>
>
>I think that's it for now ... like I said, that's just off the top of my
>head.  Anyone else?
>
>-Rick
>
>----------------------------------------------------------------------------
>--
>Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
>To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
>send a message to [EMAIL PROTECTED] with 'unsubscribe' in
>the body.
>----------------------------------------------------------------------------
>--
>Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
>To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
>send a message to [EMAIL PROTECTED] with 'unsubscribe' in
>the body.
>
>------------------------------------------------------------------------------
>Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
>To Unsubscribe visit 
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
>message to [EMAIL PROTECTED] with 'unsubscribe' in the body. 


---------------------------------------------------------------------------
Peter Theobald, Chief Technology Officer
LiquidStreaming http://www.liquidstreaming.com
[EMAIL PROTECTED]
Phone 1.212.545.1232 Fax 1.212.679.8032

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to