In Java (or any strongly-typed language), the compiler won't let code that doesn't have the right argument types compile, so you'll never have to deal with it at runtime (via exceptions). That's impossible in CF, because variables are untyped, so there is no means to typecheck until the server has actually computed the runtime value of the variable that is being passed.
Typing exceptions are almost ALWAYS programming bugs, which is why a compiler like Java's is so nice: you catch almost all type errors at compile time, not runtime. You can have the compiler skip checks where you want it to (casting), and still have to deal with that stuff at runtime (via ClassCastException), but that's the exception to the rule. Not only does CF make runtime checks the default, it doesn't provide a means to force compile-time checks at all. I'd love to see an option that would allow the CF compiler to do strong typechecking. It would not only make life a lot easier, but it'd also undoubtedly provide a nice performance boost, because you'd do all the typechecking once (compile time), rather then on every single request. Cheers, barneyb > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Nathan Dintenfass > Sent: Thursday, June 03, 2004 9:27 AM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] Catching Argument Type Errors > > Barney: > > For our education, can you explain how this is a CF issue > related to the > strongly/loosely typed hybrid? How would java deal with the > situation of > passing in the wrong kind of argument to a method call? > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Behalf Of Barney Boisvert > > Sent: Thursday, June 03, 2004 9:18 AM > > To: [EMAIL PROTECTED] > > Subject: RE: [CFCDev] Catching Argument Type Errors > > > > > > You have to catch those in the template which calls the CFC > > method, because > > control never actually passes to the CFC containing the method if > > there is a > > problem with the argument. Yet another case where MM's > strongly/loosely > > typed hybrid system makes things difficult on the developer. > > > > One solution would be to declare all your arguments as > type="any", thereby > > allowing anything in, and then do manual typechecking > inside your method, > > where you'd have full control to do whatever was necessary should > > the checks > > fail. > > > > Cheers, > > barneyb > > ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
