EasyCFM.COM ColdFusion Forums / Polls / assinate the var keyword...please!!

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Poll Topic: assinate the var keyword...please!!

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

Lossed
09-23-2007 @ 9:49 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1095
Joined: Apr 2004

Question:
Edit:** I did mean assassinate, really I did. At least I got the "ass" bit right Wink

As a function/CFC newbie, I just don't see the point of the var keyword. Why not have  all unscoped assignments in functions automatically default to a function-local scope, private to that function/method, not persisting over the life of the CFC instance, if it's a function/method in a CFC. And when in functions/methods, unscoped references (are you cringing yet, you scope-everything evangelists?) are only ever looked up by CF in the function-local scope, without looking any further if it's not there.

This message was edited by Lossed on 9-23-07 @ 9:52 PM

1. No. You got it all wrong...
2. Yes, makes perfect sense.
3. Sitting on the fence.


  
Webmaster
09-23-2007 @ 10:53 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

Without using "VAR" you will run into issues around objects being overwritten when users merge... This is mostly when under heavy load.

Sure you can assign to a session; but an object is an object. if you use a local var and two things run at the same time the second one wins... where VAR will make it two separate instance objects. So therefore; if you are going to biuld a real application Smile  you MUST use VARs...

Just thought you should know! Smile

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

Lossed
09-24-2007 @ 12:18 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1095
Joined: Apr 2004

Hi Pablo,

I'm not saying lose the "Var" functionality (heaven forbid), if that is what you are thinking (please excuse me if I'm not understanding your post correctly, or functions/CFC's/objects correctly), but rather make every unscoped assignment/reference that takes place inside a function actually default to a context that is local to that function call rather than have to explicitly assign it as such with the "var" keyword.

It just seems, at this early stage of use for me, that I'd rather ALL unscoped vars inside a function did not persist any longer than that function call and definitely not over the life of the object instance.


Lossed
---------------------------
When the only tool you have is a hammer, everything looks like a nail Smile
-----------------------------

This message was edited by Lossed on 9-26-07 @ 4:40 PM

Lossed
09-24-2007 @ 7:17 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1095
Joined: Apr 2004

Unscoped variables in cfthread default to a more restrictive thread-local context without the need for a var keyword when set. I still can't see why cffunctions couldn't have been treated in a kinda/sorta similar manner and default to function-local without the var keyword.

Sorry if that sounds dim but what am I missing?


Lossed
---------------------------
When the only tool you have is a hammer, everything looks like a nail Smile
-----------------------------


Website Designed and Developed by Pablo Varando.