It's unusual for a method to take an array of its arguments, rather
than individual ones. Situation is something like a dispatcher; the
methods already have defined arguments, say Widgets.search(widgetName,
widgetCategory, widgetID). It'd be pretty weird for it to take an
array containing those three arguments. The layer I'm talking about
wants to call that, but only has an array of argument values, in
order.

Not to be cranky, but while there's room for debate on why I want to
do this, this isn't that conversation. If there's no more elegant
approach than the switch strategy I mentioned, I'll probably ditch
this entire route. I first wanted to check if anyone could think of a
way to accomplish this in the CFML language, out of curiosity and to
maybe learn something that might be useful some day, as well to get it
done -- there's lots of smart and experienced folks out there. I
didn't mean to discuss whether it's worth doing.

Thanks,
Dave

On Wed, Oct 6, 2010 at 12:42 PM, Michael Grant <mgr...@modus.bz> wrote:
>
> Dave,
>
> Why don't you just pass in the array?
>
> <cfset positionalArgs = ['foo', 'bar', 42] />
> <cfset myFunction(positionalArgs) />
> <cffunction name="myFunction">
> <cfargument name="positionalArgs" type="array">
> <cfloop from="1" to="#arraylen(positionalArgs)#" index="x">
>  <cfdump var="#x#: #positionalArgs[x]#"><br />
> </cfloop>
> </cffunction>
>
>
> On Wed, Oct 6, 2010 at 12:38 PM, enigment <enigm...@gmail.com> wrote:
>
>>
>> @Michael: What I'm looking for is the positional equivalent of
>> argumentCollection. If it wasn't for that, you'd think the same about
>> passing a structure of arguments -- any object you pass will be
>> treated as a single argument. But argumentCollection trumps that. I
>> even tried a structure with keys 1, 2, 3, and passing that as
>> argumentCollection (unnamed arguments appear inside the function as 1,
>> 2, and 3 if you dump arguments), no joy.
>>
>> @Jason: Clearly, calling a method three times, each time with one
>> argument, is very different than calling it once with all three. Say
>> they're search fields, lastName, FirstName, ZIP; you want the search
>> to run with all three of them in place, not separately for each one.
>> (Not sure why you went with an iterator rather than just indexing over
>> the array, but it doesn't matter, not what I need to do.)
>>
>> Thanks for the ideas though. This just may not be possible.
>>
>> Dav

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337912
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to