Welcome to Dream.In.Code
Getting Help is Easy!

Join 118,862 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,682 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Custom replacement of listAppend

 
Reply to this topicStart new topic

Custom replacement of listAppend

Wubinator
post 19 Feb, 2008 - 08:25 AM
Post #1


New D.I.C Head

*
Joined: 19 Feb, 2008
Posts: 1

Hi all,

I have a question. I needed the use of listAppend. But it doesn't work so well. It even says on the livedocs that developers should not use listAppend in their code.

So I wrote my own listAppend kinda method called listAdd

CODE

<cffunction access="public" name="listAdd" output="false" returntype="String">
    <cfargument name="list" type="String" required="true">
    <cfargument name="value" type="string" required="true">
    <cfargument name="delimiter" type="string" required="false" default=",">
    <cfscript>
        if(listLen(ARGUMENTS.list) eq 0) {
            ARGUMENTS.list = ARGUMENTS.value;
        } else {
            ARGUMENTS.list = ARGUMENTS.list & ARGUMENTS.delimiter & ARGUMENTS.value;
        }
            
        return ARGUMENTS.list;
    </cfscript>
</cffunction>


This all works fine. But I have a question, is it possible to do this without returning a value, because now I call this method like this:
CODE
hashList = listAdd(hashList, this.requestObject.getIdentifier().getHashCode());


I think it would be a cleaner code if it would do the same with just:
CODE
listAdd(hashList, this.requestObject.getIdentifier().getHashCode());


But as far as I know a string has it's value copied not the memory pointer. And because a list is a string it will never change the memory location. Just the copied value.

Is there a way to make this work? Ofcourse I want changes to the listAdd() method and not the call of this method if possible.

Cheers,
Rick
User is offlineProfile CardPM

Go to the top of the page


sansclue
post 23 Feb, 2008 - 12:41 PM
Post #2


D.I.C Head

**
Joined: 21 Nov, 2007
Posts: 88



Thanked 4 times
My Contributions


QUOTE(Wubinator @ 19 Feb, 2008 - 08:25 AM) *

Hi all,

I have a question. I needed the use of listAppend. But it doesn't work so well. It even says on the livedocs that developers should not use listAppend in their code.


Specifically what problem are you having with listAppend? While it may be possible by digging into the java internals, is it really worth it? Are you having such a bad performance problem that it is worth rewriting one of the core functions.

I am not saying there may not be ways to outperform it, but if you read the comments here they say something different http://livedocs.adobe.com/coldfusion/6.1/h...cs/functib4.htm

"jrunrandy said on Mar 5, 2004 at 6:12 AM :

In testing this out, the Macromedia recommendation proves wrong. I think this comment dates back to Beta versions of ColdFusion MX and we didn't remove it after the developers fixed the code."


User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/13/08 01:48AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month