Clarification.

when using the following syntax:

<cfset request.foo = session.foo>

If session.foo is a simple variable then its value is duplicated to
request.foo and no pointer is created.

test this by doing this:

session.foo = 0;
request.foo = session.foo;
request.foo = 1;
writeoutput(session.foo);

although request.foo is now 1, session.foo is still 0, because no pointer is
craeted for simple variables.

BUT.

if session.foo is a complex variable then you are creating a pointer, and
when request.foo is changed, you're actually changing the value of
session.foo. Use the code I gave you earlier to prove this.

Re: locking:

My advice to you is to always lock any access to any shared scoped variable,
even if its a simple variable. This way you'll prevent unforeseen errors.
Shared scope variables means anything in the session, application or server
scope. 

As Tony Blair once said, Lockation. lockation. lockation.

If you can't be bothered to write loads of locks into your code, write a
function or a custom tag to do it for you and use that.

Get into the habit, and you'll always be smiling.

> -----Original Message-----
> From: Robertson-Ravo, Neil (REC)
> [mailto:Neil.Robertson-Ravo@;csd.reedexpo.com]
> Sent: 24 October 2002 10:39
> To: '[EMAIL PROTECTED]'
> Subject: RE: [ cf-dev ] Pointers / Structure again!
> 
> 
> whoah horsey :)  looks like we are all a bit vague on this issue... 
> 
> Okay, lets clarify.... take the original code I gave you (the session
> structure contains simple values and and an array):
> 
> <cflock scope="SESSION" type="READONLY" timeout="15">
>       <cfloop collection="#session#" item="key">
>               <cfset request[key] = session[key]>
>       </cfloop>
> </cflock>
> 
> So, if I code this simple variable as  : <cfset request.foo = "blah">
> 
> Does this require to be locked because its a pointer?
> 
> I have tried to prove this but it seems that it even with 
> Full Checking on,
> it doesnt bomb out.
> 
> Or are we saying that simple values are AOK, but complex 
> values such as
> arrays and structures are not?
> 
> Thanks
> 
> Neil
> 
> 
> -----Original Message-----
> From: Matt Horn [mailto:matt.horn@;mediatelgroup.co.uk]
> Sent: 24 October 2002 10:29
> To: [EMAIL PROTECTED]
> Subject: RE: [ cf-dev ] Pointers / Structure again!
> 
> 
> AAHHH
> 
>   ok
> 
>   so here you are creating a p0inter to a structure in session and in 
> variables scope
> 
> but simple values
> <cfset session.bla =10>
> 
> can be locked
> like
>   <cfset request.bla = session.bla>
> 
> yes/
> 
> 
> 
> At 10:02 24/10/2002 +0100, you wrote:
> >when they've finished laughing at that, give them the 
> following code to
> >prove that it does create a pointer:
> >
> ><cflock timeout="5" throwontimeout="No" type="EXCLUSIVE" 
> scope="SESSION">
> ><cfscript>
> >session.foo = structnew();
> >session.foo.bar = querynew("mycol");
> >queryaddrow(session.foo.bar);
> >querysetcell(session.foo.bar, "mycol", 0);
> >writeoutput('session.foo.bar.mycol[1] = ' & 
> session.foo.bar.mycol[1] &
> >'<hr>');
> >variables.apple = session.foo;
> >variables.apple.bar.mycol[1] = 1;
> >writeoutput('session.foo.bar.mycol[1] = ' & 
> session.foo.bar.mycol[1]);
> ></cfscript>
> ></cflock>
> >
> >changing the value of the variables scoped column in the bar 
> query actually
> >changes the session scoped one.
> >
> > > -----Original Message-----
> > > From: Taz -=TT=- [mailto:chris@;cfmaster.co.uk]
> > > Sent: 24 October 2002 10:15
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [ cf-dev ] Pointers / Structure again!
> > >
> > >
> > > > yep it does and I am getting it patched ASAP, but for now I
> > > need to prove
> > > > that what they are doing is wrong :-)
> > >
> > > Tell them that Taz says so
> > >
> > >
> > >
> > > --
> > > ** Archive: 
http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > For human help, e-mail: [EMAIL PROTECTED]
> >
>
>
>--
>** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
>
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>For human help, e-mail: [EMAIL PROTECTED]


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to