On 10/22/07, Sean Corfield <[EMAIL PROTECTED]> wrote:
>
> On 10/22/07, Matt Williams <[EMAIL PROTECTED]> wrote:
> > Maybe it is known or expected, but I was surprised it works. If you
> > pass arguments to a function, but don't declare them via the
> > cfargument tag, it exists anyway. You lose the name of the argument,
> > but can still access it via the arguments struct.
>
> How would you reference those arguments otherwise?

Not that I would want to, but it could be done via arguments.1,
arguments.2, etc.

>
> Could you explain *why* you thought the arguments scope would not
> exist if no arguments were passed? I'm curious as to your logic here.
> You know that you can always pass more arguments to a function than
> are declared (or maybe not and that's what led you to this position)?

It wasn't that I didn't think the arguments scope doesn't exist if no
arguments were passed, but rather any arguments not declared weren't
available to the function.

I've always assumed (and that was my first mistake) that if the
argument wasn't declared in the function (via cfargument), then it was
somehow dropped or ignored. Yes I did know you can pass more arguments
than are declared, but again, I didn't know they were actually in the
function that was called.

I found this to be of interest because of some of my coding habits
(that probably need to be changed) where I pass the entire Mach II
event arguments to my service layer
(argumentCollection=event.getArgs()). The service layer's function
declares only the needed arguments. I then loop over those arguments
to set the values in a bean.

Until now, I didn't realize I was looping over more than just what I
declared, but anything within the struct returned by event.getArgs().
With proper naming conventions it probably would never be an issue,
but I thought it would be good to be aware of nonetheless.


-- 
Matt Williams
"It's the question that drives us."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to