sync on local variable

The IntelliJ code Inspector (lint) slapped my wrist for synchronising
on a local variable.  What's the problem with that?  The sync is on
the object, not the reference, right?
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

Don�t worry about people stealing an idea; if it�s original, you�ll have to shove it down their throats. 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)
0
Roedy
3/24/2010 10:11:15 PM
comp.lang.java.programmer 52272 articles. 40 followers. Post Follow

38 Replies
293 Views

Similar Articles

[PageSpeed] 56
Roedy Green wrote:
> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
> on a local variable.  What's the problem with that?  The sync is on
> the object, not the reference, right?


Need SSCCE.

http://sscce.org/

0
markspace
3/24/2010 10:19:30 PM
Roedy Green wrote:
> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
> on a local variable.  What's the problem with that?  The sync is on
> the object, not the reference, right?

Each thread gets its own local variable. Defeats the purpose of 
synchronizing on one.

AHS
0
Arved
3/24/2010 10:46:40 PM
Arved Sandstrom wrote:
> Roedy Green wrote:
>> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
>> on a local variable.  What's the problem with that?  The sync is on
>> the object, not the reference, right?
> 
> Each thread gets its own local variable. Defeats the purpose of 
> synchronizing on one.


If you later export that local reference to another thread or object, it 
should be fine.  It's valid to synchronize on a object that some other 
part of the system will see later.

If you just synchronized on a local variable and then let it go out of 
scope, yeah, that's a pretty serious "D'oh!" moment.

0
markspace
3/24/2010 10:55:30 PM
On 24-03-2010 18:11, Roedy Green wrote:
> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
> on a local variable.  What's the problem with that?  The sync is on
> the object, not the reference, right?

Local variables are thread specific.

Passing on a local variable to another thread via some
global variable/singleton/cache would be a pretty bad design.

I can understand the complaint.

Arne

PS: yes - it is the object not the ref.
0
ISO
3/24/2010 11:09:17 PM
Arne Vajh�j wrote:
> On 24-03-2010 18:11, Roedy Green wrote:
>> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
>> on a local variable.  What's the problem with that?  The sync is on
>> the object, not the reference, right?
> 
> Local variables are thread specific.
> 
> Passing on a local variable to another thread via some
> global variable/singleton/cache would be a pretty bad design.
> 
> I can understand the complaint.
> 
> Arne
> 
> PS: yes - it is the object not the ref.

It may be a case of import, rather than export. Suppose the method for
obtaining a reference to some object is fairly expensive, and
synchronized. Each thread could have obtained a reference to the same
object and cached it in a local variable.

It's difficult to know if the message was valid or not without an SSCCE.

Patricia
0
Patricia
3/24/2010 11:21:29 PM
On 24-03-2010 19:21, Patricia Shanahan wrote:
> Arne Vajh�j wrote:
>> On 24-03-2010 18:11, Roedy Green wrote:
>>> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
>>> on a local variable. What's the problem with that? The sync is on
>>> the object, not the reference, right?
>>
>> Local variables are thread specific.
>>
>> Passing on a local variable to another thread via some
>> global variable/singleton/cache would be a pretty bad design.
>>
>> I can understand the complaint.
>
> It may be a case of import, rather than export. Suppose the method for
> obtaining a reference to some object is fairly expensive, and
> synchronized. Each thread could have obtained a reference to the same
> object and cached it in a local variable.

It could be.

But I would tend to believe that would be messy as well. To be able to
easily verify that threads are indeed synchronizing on the same object,
then I think it is best if is relative simple to see what is being
synchronized on.

> It's difficult to know if the message was valid or not without an SSCCE.

I don't think the tool does super sophisticated code analysis. Most
likely it just have some simple rules and flag things that looks weird.
If they are good enough, then the developer can ignore the warning. And
a good tool would have the option to store the ignore decision.

Arne
0
ISO
3/24/2010 11:27:28 PM
Roedy Green wrote:
> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
> on a local variable.  What's the problem with that?  The sync is on
> the object, not the reference, right?

Right, it's not illegal and may be correct.  But it may be incorrect as 
well, and probably is will be unless you can guarantee that the local will 
point to the same instance in all threads.  IntelliJ thinks enough people 
make that mistake that it's worth warning about. It's similar to

    while (methodCall());
        i++;

That's legal and  might be exactly what you meant to do, but the first 
semicolon is likely enough to be spurious that a lint-like tool should say 
something. 


0
Mike
3/24/2010 11:36:39 PM
markspace wrote:
> Arved Sandstrom wrote:
>> Roedy Green wrote:
>>> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
>>> on a local variable.  What's the problem with that?  The sync is on
>>> the object, not the reference, right?
>>
>> Each thread gets its own local variable. Defeats the purpose of 
>> synchronizing on one.
> 
> 
> If you later export that local reference to another thread or object, it 
> should be fine.  It's valid to synchronize on a object that some other 
> part of the system will see later.
> 
> If you just synchronized on a local variable and then let it go out of 
> scope, yeah, that's a pretty serious "D'oh!" moment.
> 
I think all the responses have pretty much narrowed in on the same 
things: the sync is indeed on the object, which means that however you 
obtain/store a reference to that object that everything is using as a 
lock, it's certainly legal to sync on an object referred to locally.

But since it's something that is somewhat unusual, and could (probably) 
be a  mistake, I imagine IntelliJ is flagging it along the lines of what 
Mike suggested.

AHS
0
Arved
3/25/2010 12:32:59 AM
On Wed, 24 Mar 2010 15:55:30 -0700, markspace <nospam@nowhere.com>
wrote, quoted or indirectly quoted someone who said :

>If you later export that local reference to another thread or object, it 
>should be fine.  It's valid to synchronize on a object that some other 
>part of the system will see later.

I have a JTable.  I get a row put it in a local variable and
synchronise on that.   Does that not lock anyone else getting that
row, even if they have nothing to do with my local variable?

 AppToWatch row;
 synchronized ( ALL_ROWS )
                {
                row = ALL_ROWS.get( rowIndex );
                state = row.getState();
                }
....
  synchronized ( row )
                    {
                    url = row.getVersionURL();
                    marker = row.getMarker();
                    }
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

Don�t worry about people stealing an idea; if it�s original, you�ll have to shove it down their throats. 
~ Howard Aiken (born: 1900-03-08 died: 1973-03-14 at age: 73)
0
Roedy
3/25/2010 12:42:02 AM
On 24-03-2010 20:42, Roedy Green wrote:
> On Wed, 24 Mar 2010 15:55:30 -0700, markspace<nospam@nowhere.com>
> wrote, quoted or indirectly quoted someone who said :
>> If you later export that local reference to another thread or object, it
>> should be fine.  It's valid to synchronize on a object that some other
>> part of the system will see later.
>
> I have a JTable.  I get a row put it in a local variable and
> synchronise on that.   Does that not lock anyone else getting that
> row, even if they have nothing to do with my local variable?

It does.

But the code would probably be difficult to read and this
is why a code style checker flag it.

Arne
0
ISO
3/25/2010 1:25:16 AM
On 3/24/2010 8:42 PM, Roedy Green wrote:
> On Wed, 24 Mar 2010 15:55:30 -0700, markspace<nospam@nowhere.com>
> wrote, quoted or indirectly quoted someone who said :
>
>> If you later export that local reference to another thread or object, it
>> should be fine.  It's valid to synchronize on a object that some other
>> part of the system will see later.
>
> I have a JTable.  I get a row put it in a local variable and
> synchronise on that.   Does that not lock anyone else getting that
> row, even if they have nothing to do with my local variable?
>
>   AppToWatch row;
>   synchronized ( ALL_ROWS )
>                  {
>                  row = ALL_ROWS.get( rowIndex );
>                  state = row.getState();
>                  }
> ...
>    synchronized ( row )
>                      {
>                      url = row.getVersionURL();
>                      marker = row.getMarker();
>                      }

     Are you sure you didn't misread IntelliJ's complaint?  The
thing that strikes me as odd about this code is that there are
three method calls made on row's object, only two of which are
synchronized on that object.  It's conceivable that this is all
right, but it sure looks strange to me -- and perhaps IntelliJ
thinks it peculiar, too.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
Eric
3/25/2010 4:06:56 AM
On 3/24/2010 5:42 PM, Roedy Green wrote:
> On Wed, 24 Mar 2010 15:55:30 -0700, markspace<nospam@nowhere.com>
> wrote, quoted or indirectly quoted someone who said :
>
>> If you later export that local reference to another thread or object, it
>> should be fine.  It's valid to synchronize on a object that some other
>> part of the system will see later.
>
> I have a JTable.  I get a row put it in a local variable and
> synchronise on that.   Does that not lock anyone else getting that
> row, even if they have nothing to do with my local variable?
>
>   AppToWatch row;
>   synchronized ( ALL_ROWS )
>                  {
>                  row = ALL_ROWS.get( rowIndex );
>                  state = row.getState();
>                  }
> ....
>    synchronized ( row )
>                      {
>                      url = row.getVersionURL();
>                      marker = row.getMarker();
>                      }
I can't say for sure without seeing more of the code, but this looks 
like a road to deadlock.

-- 
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
0
Daniel
3/25/2010 4:50:29 PM
On Thu, 25 Mar 2010 00:06:56 -0400, Eric Sosman
<esosman@ieee-dot-org.invalid> wrote, quoted or indirectly quoted
someone who said :

>     Are you sure you didn't misread IntelliJ's complaint?  

all it says is  "synchronization on local variable row".
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

If you tell a computer the same fact in more than one place, unless you have an automated mechanism to ensure           they stay in sync, the versions of the fact will eventually get out of sync.
0
Roedy
3/25/2010 5:23:26 PM
On Thu, 25 Mar 2010 00:06:56 -0400, Eric Sosman
<esosman@ieee-dot-org.invalid> wrote, quoted or indirectly quoted
someone who said :

>>   AppToWatch row;
>>   synchronized ( ALL_ROWS )
>>                  {
>>                  row = ALL_ROWS.get( rowIndex );
>>                  state = row.getState();
>>                  }
>> ...
>>    synchronized ( row )
>>                      {
>>                      url = row.getVersionURL();
>>                      marker = row.getMarker();
>>                      }
>
>     Are you sure you didn't misread IntelliJ's complaint?  The
>thing that strikes me as odd about this code is that there are
>three method calls made on row's object, only two of which are
>synchronized on that object.  It's conceivable that this is all
>right, but it sure looks strange to me -- and perhaps IntelliJ
>thinks it peculiar, too.

I corrected the code to read:

   AppToWatch row;
   synchronized ( ALL_ROWS )
                  {
                  row = ALL_ROWS.get( rowIndex );
                  synchronized ( row )
                      {
                      state = row.getState();
                      }
                  }
 ...
    synchronized ( row )
                      {
                      url = row.getVersionURL();
                      marker = row.getMarker();
                      }
                    
Now I get TWO message about synchorizing on row.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

If you tell a computer the same fact in more than one place, unless you have an automated mechanism to ensure           they stay in sync, the versions of the fact will eventually get out of sync.
0
Roedy
3/25/2010 5:27:31 PM
On Wed, 24 Mar 2010 16:21:29 -0700, Patricia Shanahan <pats@acm.org>
wrote, quoted or indirectly quoted someone who said :

>It's difficult to know if the message was valid or not without an SSCCE.

you can see the complete code at
https://wush.net/websvn/mindprod/listing.php?repname=mindprod&path=/com/mindprod/vercheck/

it is a bit fat for a SSCCE.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

If you tell a computer the same fact in more than one place, unless you have an automated mechanism to ensure           they stay in sync, the versions of the fact will eventually get out of sync.
0
Roedy
3/25/2010 5:29:46 PM
On 3/25/2010 1:27 PM, Roedy Green wrote:
> [...]
> Now I get TWO message about synchorizing on row.

     A politician would call this "Progress."  ;-)

     Sorry; I'm out of ideas about what IntelliJ dislikes.  Let
us know if (no, let's be optimistic, "when") you find out; it'll
probably be interesting and/or instructive.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
Eric
3/25/2010 5:38:21 PM
Roedy Green wrote:
> it is a bit fat for a SSCCE.

Well, the point of an SSCCE is that you trim down the "fat" code to a
minimal case that illustrates the problem.  Part of the value in doing
that is that you often find the problem in the course of doing the
trimming.

Eric Sosman
>> =A0 =A0 Are you sure you didn't misread IntelliJ's complaint? =A0The
>> thing that strikes me as odd about this code is that there are
>> three method calls made on row's object, only two of which are
>> synchronized on that object. =A0It's conceivable that this is all
>> right, but it sure looks strange to me -- and perhaps IntelliJ
>> thinks it peculiar, too.
>

Roedy Green wrote:
> I corrected the code to read:
>
> =A0 =A0AppToWatch row;
> =A0 =A0synchronized ( ALL_ROWS )
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 row =3D ALL_ROWS.get( rowIndex );
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 synchronized ( row )
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 state =3D row.getState();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> =A0...

It's not clear to me how this next section gets its 'row' reference.
Presumably it has to synchronize on 'ALL_ROWS' via the above
fragment.  Regardless, any time you have inconsistent locking
protocols, e.g., using two locks in one place and only one in another,
you risk having strange problems, so it makes sense that IntelliJ
warns you about it.  As with "unchecked" warnings, that doesn't mean
that you're wrong, necessarily, only that you're in dangerous
territory.

> =A0 =A0 synchronized ( row )
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 url =3D row.getVersionURL();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 marker =3D row.getMarker();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>
> Now I get TWO message about synchorizing on row.
>

It's very difficult to reason about locks and synchronization when
they depend on changeable references, and involve different locking
sequences.  I swan the warning is appropriate and you should either
live with it or come up with a locking protocol that's easier to
understand.

--
Lew
0
Lew
3/25/2010 6:01:30 PM
On 3/25/2010 1:29 PM, Roedy Green wrote:
> On Wed, 24 Mar 2010 16:21:29 -0700, Patricia Shanahan<pats@acm.org>
> wrote, quoted or indirectly quoted someone who said :
>
>> It's difficult to know if the message was valid or not without an SSCCE.
>
> you can see the complete code at
> https://wush.net/websvn/mindprod/listing.php?repname=mindprod&path=/com/mindprod/vercheck/
>
> it is a bit fat for a SSCCE.

     Would have been nice of you to point out which of the twelve
source files elicited the complaint ...  For others who may want
a look, VerCheck.java seems to be the culprit.

     Roedy, I still don't know what's going on, but there's at least
one synchronization problem apparent in the code:

    for ( int rowIndex = 0; rowIndex < ALL_ROWS.size(); rowIndex++ )
       ...
       synchronized ( ALL_ROWS )
           {
           row = ALL_ROWS.get( rowIndex );

As the comment just before this loop says, rows might be deleted
from ALL_ROWS while this is running, meaning that rowIndex might
be out of range by the time you call get().

     This doesn't appear closely related to a complaint about
synchronizing on row -- but I've often found, when confronted
by a mysterious problem, that it pays to clean up *all* the
other issues, even those that are "obviously unrelated."

     By the way, if ALL_ROWS can be perturbed while the loop is
in progress, the iteration may miss rows (visit row 4, other
thread deletes row 2 and slides everything down one slot, visit
row 5 which used to be row 6, never visit the old row 5), or may
visit a row more than once (visit row 4, other thread inserts a
row after row 2 and slides everything up, visit row 5 which is
the same row just visited as 4).  The comment indicates you don't
want to lock ALL_ROWS for the entire loop, but to keep the
iteration self-consistent you might want to do something like
lock ALL_ROWS, grab a snapshot with toArray(), unlock, and run
the iteration on the (private, stable) snapshot.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
Eric
3/25/2010 6:06:53 PM
On Thu, 25 Mar 2010 11:01:30 -0700 (PDT), Lew <lew@lewscanon.com>
wrote, quoted or indirectly quoted someone who said :

>> it is a bit fat for a SSCCE.
>
>Well, the point of an SSCCE is that you trim down the "fat" code to a
>minimal case that illustrates the problem.  Part of the value in doing
>that is that you often find the problem in the course of doing the
>trimming.

The problem is any piece of code with a JTable in it and TableModel is
still going to be obese.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

If you tell a computer the same fact in more than one place, unless you have an automated mechanism to ensure           they stay in sync, the versions of the fact will eventually get out of sync.
0
Roedy
3/25/2010 6:35:38 PM
Roedy Green wrote :
> On Thu, 25 Mar 2010 00:06:56 -0400, Eric Sosman
> <esosman@ieee-dot-org.invalid> wrote, quoted or indirectly quoted
> someone who said :
>
> I corrected the code to read:

Have you tried to explicitly initialise row?

AppToWatch row = null;

>    synchronized ( ALL_ROWS )
>                   {
>                   row = ALL_ROWS.get( rowIndex );
>                   synchronized ( row )
>                       {
>                       state = row.getState();
>                       }
>                   }
>  ...
>     synchronized ( row )
>                       {
>                       url = row.getVersionURL();
>                       marker = row.getMarker();
>                       }
>                     
> Now I get TWO message about synchorizing on row.

-- 
Wojtek :-)


0
Wojtek
3/25/2010 6:48:26 PM
On 3/25/2010 11:35 AM, Roedy Green wrote:
> On Thu, 25 Mar 2010 11:01:30 -0700 (PDT), Lew<lew@lewscanon.com>
> wrote, quoted or indirectly quoted someone who said :
>
>>> it is a bit fat for a SSCCE.
>>
>> Well, the point of an SSCCE is that you trim down the "fat" code to a
>> minimal case that illustrates the problem.  Part of the value in doing
>> that is that you often find the problem in the course of doing the
>> trimming.
>
> The problem is any piece of code with a JTable in it and TableModel is
> still going to be obese.
Do you believe your problem is because of those classes? If not, you can 
write an SSCCE that doesn't use them.

-- 
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
0
Daniel
3/25/2010 7:23:31 PM
On 3/25/2010 11:06 AM, Eric Sosman wrote:
> On 3/25/2010 1:29 PM, Roedy Green wrote:
>> On Wed, 24 Mar 2010 16:21:29 -0700, Patricia Shanahan<pats@acm.org>
>> wrote, quoted or indirectly quoted someone who said :
>>
>>> It's difficult to know if the message was valid or not without an SSCCE.
>>
>> you can see the complete code at
>> https://wush.net/websvn/mindprod/listing.php?repname=mindprod&path=/com/mindprod/vercheck/
>>
>>
>> it is a bit fat for a SSCCE.
>
> Would have been nice of you to point out which of the twelve
> source files elicited the complaint ... For others who may want
> a look, VerCheck.java seems to be the culprit.
>
> Roedy, I still don't know what's going on, but there's at least
> one synchronization problem apparent in the code:
>
> for ( int rowIndex = 0; rowIndex < ALL_ROWS.size(); rowIndex++ )
> ...
> synchronized ( ALL_ROWS )
> {
> row = ALL_ROWS.get( rowIndex );
>
> As the comment just before this loop says, rows might be deleted
> from ALL_ROWS while this is running, meaning that rowIndex might
> be out of range by the time you call get().
>
> This doesn't appear closely related to a complaint about
> synchronizing on row -- but I've often found, when confronted
> by a mysterious problem, that it pays to clean up *all* the
> other issues, even those that are "obviously unrelated."
>
> By the way, if ALL_ROWS can be perturbed while the loop is
> in progress, the iteration may miss rows (visit row 4, other
> thread deletes row 2 and slides everything down one slot, visit
> row 5 which used to be row 6, never visit the old row 5), or may
> visit a row more than once (visit row 4, other thread inserts a
> row after row 2 and slides everything up, visit row 5 which is
> the same row just visited as 4). The comment indicates you don't
> want to lock ALL_ROWS for the entire loop, but to keep the
> iteration self-consistent you might want to do something like
> lock ALL_ROWS, grab a snapshot with toArray(), unlock, and run
> the iteration on the (private, stable) snapshot.
I agree except, don't use toArray, use new ArrayList<Row>();
Or, instead of all the sync, check, blah-de-blah, use the standard EDT 
mechanisms for modifying/accessing this table.  That way, you're actions 
are all serial, and you don't have to worry so much.

Threading isn't that hard to get right, but it isn't that hard to get 
wrong either. The only truly difficult part of writing MT code is that 
people aren't taught how to look at it and determine whether it is right 
or not.


-- 
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
0
Daniel
3/25/2010 7:28:45 PM
On Thu, 25 Mar 2010 11:01:30 -0700 (PDT), Lew <lew@lewscanon.com>
wrote, quoted or indirectly quoted someone who said :

>It's very difficult to reason about locks and synchronization when
>they depend on changeable references,

They don't.  The two variables are final in the real code.  I
"simplified". My bad.

I think the problem is just that in general local variables can be
subject to casual modification, perhaps during a later patch, which
would break the lock.
 
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

If you tell a computer the same fact in more than one place, unless you have an automated mechanism to ensure           they stay in sync, the versions of the fact will eventually get out of sync.
0
Roedy
3/25/2010 9:27:46 PM
On Wed, 24 Mar 2010 15:11:15 -0700, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>The IntelliJ code Inspector (lint) slapped my wrist for synchronising
>on a local variable.  What's the problem with that?  The sync is on
>the object, not the reference, right?

I got this response from an IntelliJ employee (probably a Russian with
ESL).

The point was synchronization only makes sense if two different
threads syncing on the same instance and question arises how safe was
an exchange, that two threads have same reference on their stacks.
Most obviously "clean" subject to synchronize on is a final field.
Synchronizing on a local reference might well be not a problem but
generally not that easy to verify for correctness and easy thing to
broke later.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

If you tell a computer the same fact in more than one place, unless you have an automated mechanism to ensure           they stay in sync, the versions of the fact will eventually get out of sync.
0
Roedy
3/25/2010 9:27:50 PM
On Thu, 25 Mar 2010 14:06:53 -0400, Eric Sosman
<esosman@ieee-dot-org.invalid> wrote, quoted or indirectly quoted
someone who said :

>     Would have been nice of you to point out which of the twelve
>source files elicited the complaint ...  For others who may want
>a look, VerCheck.java seems to be the culprit.

 Sorry  I thought I had pointed you to Vercheck.java.

It has since occurred to me I could try concocting a much simpler
piece of code without any JTable that still triggered the lint.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

If you tell a computer the same fact in more than one place, unless you have an automated mechanism to ensure           they stay in sync, the versions of the fact will eventually get out of sync.
0
Roedy
3/25/2010 9:29:33 PM
On Thu, 25 Mar 2010 12:28:45 -0700, Daniel Pitts
<newsgroup.spamfilter@virtualinfinity.net> wrote, quoted or indirectly
quoted someone who said :

>Threading isn't that hard to get right, but it isn't that hard to get 
>wrong either. The only truly difficult part of writing MT code is that 
>people aren't taught how to look at it and determine whether it is right 
>or not.

The compiler rarely complains and the program nearly always run one
thread at a time. You can't easily simulate pathological cases the way
you can with single thread.  Perhaps there is some drug that induces
paranoia that could be used once you have your first cut.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com

If you tell a computer the same fact in more than one place, unless you have an automated mechanism to ensure           they stay in sync, the versions of the fact will eventually get out of sync.
0
Roedy
3/25/2010 9:32:39 PM
Roedy Green wrote:

> I got this response from an IntelliJ employee (probably a Russian with
> ESL).


Hmm, well that's one strike against IntelliJ then, if they don't hire 
tech support that can communicate properly.
0
markspace
3/25/2010 10:12:36 PM
On 25-03-2010 17:27, Roedy Green wrote:
> On Wed, 24 Mar 2010 15:11:15 -0700, Roedy Green
> <see_website@mindprod.com.invalid>  wrote, quoted or indirectly quoted
> someone who said :
>> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
>> on a local variable.  What's the problem with that?  The sync is on
>> the object, not the reference, right?
>
> I got this response from an IntelliJ employee (probably a Russian with
> ESL).
>
> The point was synchronization only makes sense if two different
> threads syncing on the same instance and question arises how safe was
> an exchange, that two threads have same reference on their stacks.
> Most obviously "clean" subject to synchronize on is a final field.
> Synchronizing on a local reference might well be not a problem but
> generally not that easy to verify for correctness and easy thing to
> broke later.

JetBrains is a czech company, so czech not russian sounds more
likely.

But the text looks fine to me. It is more or less what we
have been telling you for two days.

Arne

0
ISO
3/25/2010 11:41:39 PM
On 25-03-2010 15:28, Daniel Pitts wrote:
> Threading isn't that hard to get right, but it isn't that hard to get
> wrong either. The only truly difficult part of writing MT code is that
> people aren't taught how to look at it and determine whether it is right
> or not.

That applies to other things than MT!

:-)

Arne

0
ISO
3/25/2010 11:59:28 PM
On Wed, 24 Mar 2010, Roedy Green wrote:

> The IntelliJ code Inspector (lint) slapped my wrist for synchronising on 
> a local variable.  What's the problem with that?  The sync is on the 
> object, not the reference, right?

It's like the warning on the lack of a serialVersionUID in a Serializable 
class. It isn't necessarily wrong, but there is a popular class of errors 
that involve doing this.

tom

-- 
life finds a way
0
Tom
3/26/2010 3:01:49 AM
On 3/25/2010 3:28 PM, Daniel Pitts wrote:
> On 3/25/2010 11:06 AM, Eric Sosman wrote:
 >> [... about iterating over a changing List ...]
>> to keep the
>> iteration self-consistent you might want to do something like
>> lock ALL_ROWS, grab a snapshot with toArray(), unlock, and run
>> the iteration on the (private, stable) snapshot.
 >
> I agree except, don't use toArray, use new ArrayList<Row>();

     Not confrontational, just curious: Why prefer a new ArrayList
to an array?  To me, it appears that an ArrayList is just an array
wrapped up in extra machinery, and I can't see that the machinery
adds any value for this usage.  So, why pay the extra freight?
What am I missing?

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
Eric
3/26/2010 2:22:01 PM
On 3/26/2010 7:22 AM, Eric Sosman wrote:
> On 3/25/2010 3:28 PM, Daniel Pitts wrote:
>> On 3/25/2010 11:06 AM, Eric Sosman wrote:
>  >> [... about iterating over a changing List ...]
>>> to keep the
>>> iteration self-consistent you might want to do something like
>>> lock ALL_ROWS, grab a snapshot with toArray(), unlock, and run
>>> the iteration on the (private, stable) snapshot.
>  >
>> I agree except, don't use toArray, use new ArrayList<Row>();
>
> Not confrontational, just curious: Why prefer a new ArrayList
> to an array? To me, it appears that an ArrayList is just an array
> wrapped up in extra machinery, and I can't see that the machinery
> adds any value for this usage. So, why pay the extra freight?
> What am I missing?
Array is a relatively primitive concept. You're question is akin to 
asking why use a "Date object" instead of an "int representing the 
milliseconds since Jan 1, 1970".

Either one "works". Yes, the non-primitive has more "machinery", but 
that isn't automatically a bad thing.  The primitive looses semantic 
meaning outside of its context, where a properly designed abstraction 
maintains its semantics regardless of context.

Lists are also easier to work with, and work in more places.

-- 
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
0
Daniel
3/26/2010 8:15:47 PM
On 3/25/2010 2:27 PM, Roedy Green wrote:
> On Wed, 24 Mar 2010 15:11:15 -0700, Roedy Green
> <see_website@mindprod.com.invalid>  wrote, quoted or indirectly quoted
> someone who said :
>
>> The IntelliJ code Inspector (lint) slapped my wrist for synchronising
>> on a local variable.  What's the problem with that?  The sync is on
>> the object, not the reference, right?
>
> I got this response from an IntelliJ employee (probably a Russian with
> ESL).
>
> The point was synchronization only makes sense if two different
> threads syncing on the same instance and question arises how safe was
> an exchange, that two threads have same reference on their stacks.
> Most obviously "clean" subject to synchronize on is a final field.
> Synchronizing on a local reference might well be not a problem but
> generally not that easy to verify for correctness and easy thing to
> broke later.
One thing you can do is more the synchronization into the "Row" class, 
and turn your operations into atomic operations, rather than have 
external clients need to concern themselves with synchronization.

That way, the Row class can always sync on the same object (probably 
"this", but not necessarily), and the client needn't care about it.

-- 
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
0
Daniel
3/26/2010 8:18:07 PM
Daniel Pitts wrote:
> On 3/26/2010 7:22 AM, Eric Sosman wrote:
>> On 3/25/2010 3:28 PM, Daniel Pitts wrote:
>>> On 3/25/2010 11:06 AM, Eric Sosman wrote:
>>  >> [... about iterating over a changing List ...]
>>>> to keep the
>>>> iteration self-consistent you might want to do something like
>>>> lock ALL_ROWS, grab a snapshot with toArray(), unlock, and run
>>>> the iteration on the (private, stable) snapshot.
>>  >
>>> I agree except, don't use toArray, use new ArrayList<Row>();
>>
>> Not confrontational, just curious: Why prefer a new ArrayList
>> to an array? To me, it appears that an ArrayList is just an array
>> wrapped up in extra machinery, and I can't see that the machinery
>> adds any value for this usage. So, why pay the extra freight?
>> What am I missing?
> Array is a relatively primitive concept. You're question is akin to 
> asking why use a "Date object" instead of an "int representing the 
> milliseconds since Jan 1, 1970".
> 
> Either one "works". Yes, the non-primitive has more "machinery", but 
> that isn't automatically a bad thing.  The primitive looses semantic 
> meaning outside of its context, where a properly designed abstraction 
> maintains its semantics regardless of context.
> 
> Lists are also easier to work with, and work in more places.
> 
I tend to use an array where the underlying structure I am representing 
really is an array, and a collection where the underlying structure 
really is a list or set or whatever.

Specifically I am not going to use an ArrayList, for example, if the 
thing being modelled is not resizable. Why would I want to write code to 
ensure that the ArrayList will stay at a fixed size when an aray will 
already take care of that for me?

AHS
0
Arved
3/26/2010 9:05:27 PM
On 3/26/2010 4:15 PM, Daniel Pitts wrote:
> On 3/26/2010 7:22 AM, Eric Sosman wrote:
>> On 3/25/2010 3:28 PM, Daniel Pitts wrote:
>>> On 3/25/2010 11:06 AM, Eric Sosman wrote:
>> >> [... about iterating over a changing List ...]
>>>> to keep the
>>>> iteration self-consistent you might want to do something like
>>>> lock ALL_ROWS, grab a snapshot with toArray(), unlock, and run
>>>> the iteration on the (private, stable) snapshot.
>> >
>>> I agree except, don't use toArray, use new ArrayList<Row>();
>>
>> Not confrontational, just curious: Why prefer a new ArrayList
>> to an array? To me, it appears that an ArrayList is just an array
>> wrapped up in extra machinery, and I can't see that the machinery
>> adds any value for this usage. So, why pay the extra freight?
>> What am I missing?
> Array is a relatively primitive concept. You're question is akin to
> asking why use a "Date object" instead of an "int representing the
> milliseconds since Jan 1, 1970".

     I think you've over-generalized my question.  I'm not
asking whether arrays or Lists (longs or Dates) are preferable
in all circumstances, nor even in most circumstances.  Rather,
I'm asking why you prefer the "heavier" object in the particular
situation Roedy faces.

> Either one "works". Yes, the non-primitive has more "machinery", but
> that isn't automatically a bad thing.

     Okay.  I'd also say it's not automatically a good thing,
especially when the machinery is not going to be used.

     How much extra machinery are we talking about, in this specific
case?  I'm suggesting a call to toArray() followed by an iteration
over the array: One new object created.  A new ArrayList involves
creating that same array (perhaps twice, but I don't know whether
that happens here; there's a bug number I haven't looked up), creates
the ArrayList itself, and creates an Iterator when you actually do
the traversal.  Three (four?) new objects instead of one.

     How heavy are the extra objects?  The ArrayList carries two
fields, plus another inherited from AbstractList.  The Iterator
carries four more fields (you'll only see three in the source,
but inner classes carry a hidden reference to their owner).
During the iteration, the Iterator carefully checks whether the
ArrayList has been modified; we know it will not have been (the
reason we made the snapshot was so no modifications would disturb
us).  Each item retrieved takes three bounds checks (nominally)
instead of one: One in hasNext(), one in next(), and one in the
actual array fetch.  And so on.

     Okay, okay, okay: Memory's cheap, CPU's are fast, only misers
count their change.  But on the other hand, "Take care of the
pennies and the pounds will take care of themselves," and "Don't
use a cannon to kill a canary."

> The primitive looses semantic
> meaning outside of its context, where a properly designed abstraction
> maintains its semantics regardless of context.

     The comparison is between an array and an ArrayList.  The
only semantic difference I see between them is that the latter
can grow and shrink, while the former cannot.  But in the case
at hand, the goal is to get a snapshot that will remain unchanged,
that is, to avoid growth and shrinkage.  Again, it seems to me
we're paying for capabilities that will not be used.

> Lists are also easier to work with, and work in more places.

     Once again, I return to the particular use in consideration.
The comparison is between

	Row[] rows;
	synchronized(ALL_ROWS) {
	    rows = ALL_ROWS.toArray(new Row[ALL_ROWS.size()]);
	}
	for (Row r : rows) { ... }

and

	ArrayList<Row> rows;
	synchronized(ALL_ROWS) {
	    rows = new ArrayList<Row>(ALL_ROWS);
	}
	for (Row r : rows) { ... }

There's only one "place" to consider, but still: Point to you
for being easier by five keystrokes.  (With a simple change I
could get a fourteen-key swing and beat you by nine, but at the
cost of creating two arrays instead of one.)

     Even though my first language was FORTRAN, I have no special
love for the array nor no special antipathy for the List.  I'm
happy to use either.  But I *do* have a preference for lighter-
weight gadgets when they're adequate for the purpose at hand, and
a Yankee's aversion to paying for unused extras.  YM[*]MV.

     [*] Motivation.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
Eric
3/26/2010 9:33:16 PM
On 3/26/2010 4:18 PM, Daniel Pitts wrote:
> [...]
> One thing you can do is more the synchronization into the "Row" class,
> and turn your operations into atomic operations, rather than have
> external clients need to concern themselves with synchronization.
>
> That way, the Row class can always sync on the same object (probably
> "this", but not necessarily), and the client needn't care about it.

     Are you sure he can do that?  He calls three methods on
the row instance, in two synchronized blocks.  Split them into
three blocks, and the pair that were together may no longer see
their row in the same state, because something may happen after
one method releases the lock and before the next acquires it.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
Eric
3/26/2010 10:19:03 PM
On 26-03-2010 10:22, Eric Sosman wrote:
> On 3/25/2010 3:28 PM, Daniel Pitts wrote:
>> On 3/25/2010 11:06 AM, Eric Sosman wrote:
>  >> [... about iterating over a changing List ...]
>>> to keep the
>>> iteration self-consistent you might want to do something like
>>> lock ALL_ROWS, grab a snapshot with toArray(), unlock, and run
>>> the iteration on the (private, stable) snapshot.
>  >
>> I agree except, don't use toArray, use new ArrayList<Row>();
>
> Not confrontational, just curious: Why prefer a new ArrayList
> to an array? To me, it appears that an ArrayList is just an array
> wrapped up in extra machinery, and I can't see that the machinery
> adds any value for this usage. So, why pay the extra freight?
> What am I missing?

As a general rule:

know that more functionality than array will be needed in the future => 
pick ArrayList

know that more functionality than array will NOT be needed in the future 
=> pick array

don't know if more functionality than array will be needed in the future 
=> pick ArrayList

My assumption would be that in the real world that would be 10%-10%-80%.

Obviously you can argue that this seems fell in category #2.

Arne



0
ISO
3/27/2010 12:59:50 AM
On 3/26/2010 3:19 PM, Eric Sosman wrote:
> On 3/26/2010 4:18 PM, Daniel Pitts wrote:
>> [...]
>> One thing you can do is more the synchronization into the "Row" class,
>> and turn your operations into atomic operations, rather than have
>> external clients need to concern themselves with synchronization.
>>
>> That way, the Row class can always sync on the same object (probably
>> "this", but not necessarily), and the client needn't care about it.
>
> Are you sure he can do that? He calls three methods on
> the row instance, in two synchronized blocks. Split them into
> three blocks, and the pair that were together may no longer see
> their row in the same state, because something may happen after
> one method releases the lock and before the next acquires it.

The first call is synchronized separately.  The second and third call 
are in one synchronized block.  The "atomicity" of those two calls can 
be handled in one method:

class MarkedUrl {
    private final VersionURL url;
    private final Marker marker;

    // appropriate contstructor and getters.
}

public class AppToWatch  {
   public syncronized MarkedUrl getMarkedUrl() {
    return new MarkedUrl(versionUrl, marker);
   }
}


-- 
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
0
Daniel
3/29/2010 7:52:35 PM
Reply:
Similar Artilces:

T5 e-mail sync to Outlook Express
Hi everyone, I've just switched to using the Palm Desktop and Outlook Express to sync my T5, as opposed to Outlook. The problem is, the Folder Sync box in Versamail is ghosted out, which is not much help and I do have other folders as well as the standard ones. Any ideas? Paul ...

Local C source control
Is there any software that allows source control like cvs or perforce, but on your local machine? Displacer wrote: > Is there any software that allows source control like cvs or perforce, > but on your local machine? cvs works fine on the local machine. For new projects, I like git--it's phenominally easy to set up a single-user version control. Just go into the directory you want and run "git-init-db" and then you can add, commit, checkout, etc. Displacer wrote: > Is there any software that allows source control like cvs or perforce, > but on your local machin...

local copy of rubyforge
Hello All, Is there a way that I can maintain a local copy of all gems, from let'= s say rubyforge? (or any other repo for that matter). I'd like to maintain= a local repo for ruby gems in our network which doesn't permit for outside= access. I figured I can have the one machine that has external access, to= sync up files daily during off hours. This is kind of what I already do w= ith Yum repos. My current gem version is 1.3.7. =20 I understand that I can run my own gem server via 'gem server -d /dir'= , and it'll run on 8808. I'm just...

shell script to read id3 tags
I'm trying to write a script which will output the id3 details of an mp3 track to an lcd display. I thought the following would get the album, artist, and title into the variables $a, $g, $v, but they don't stay there after the end of the while loop. Is there a way round this? #!/bin/sh id3v2 -l $1 | grep -A10 '^id3v2 tag info' | while read f ; do p=`echo $f | cut '-d ' -f1` v=`echo $f | cut '-d:' -f2 | cut -c2-` echo "$p-$v" if [ "$p" = "Album/Movie/Show" ] ; then a="$v" ; echo "--$a" ...

Can you sync documents with .mac?
I see how .mac can sync bookmarks, ical, address book, and mail. Can it as well sync your documents folder? I'm not concerned about videos, music, and pictures since I don't update them often but I'm always on the go or at home updating documents and would like if they could be synced through .mac. If not, is there another good solution for the mac to sync documents? I want to add also, for syncing between multiple macs can you do this with one single .mac account or do you need a family pack for the multiple macs? In article <gmmik2l3j9m8dnoqcmbeac1fhrfanb36hb@4ax.com>, MW...

Problems with parfor, sim and non local workers
Hello, i have problems using parfor with the sim-command and using non local workers. With local workers the scripts works fine, without any problems. (A couple (numSimulations) of different parameter sets are stored in the cell Simulation. I am using rapid Acceleration target and tuneable parameters therfore) mdl=&#8217;test_simulation&#8217;; matlabpool open local out = cell(1, numSimulations); parfor(i = 1:numSimulations) out{i} = sim(mdl, Simulationen{i}); end matlapool close But when i use non local workers (the config with the parallel Configuration Manager ...

Color sync
My dad's fruit flavored iMac (10.3.3) has been printing photo's much darker under sys 10.3.3 than it did under 9.2.2. I can improve it print to print by going to color and selecting lighter. Is there a way I can permanently change the color curve so he does not have to go through the 5 extra steps every time he prints a photo? The printer is an HP all in one 750. jim <dontthinkso@nuhuh.org> wrote: > My dad's fruit flavored iMac (10.3.3) has been printing photo's much > darker under sys 10.3.3 than it did under 9.2.2. > > I can improve it print to pri...

variable arrays
Hi! Is it possible to define arrays of variable length? I explain better: an array whose length is unknown because it will be "filled" if a certain condition is satisfied. Below is an example (does not work): Thank you, celevic PROGRAM proof_array implicit none integer :: i,j,n integer,allocatable :: A(:) integer, dimension(10) :: B=(/(i, i=1,10,1)/) n=0 do j=1,10,1 if (j<6) then A(j)=j n=n+1 endif enddo allocate(A(1:n)) write(*,100) A 100 format (I) END PROGRAM celevic wrote: > > Hi! > Is it possible to define arrays of variable len...

plot points defined by a variable
Hy! I having a really simple problem. I plotted a curve and I want to identify some points on that curve. The point are defined by an equation. But I'm having trouble trying to plot those. For example, the following doesn't work: unset label set samples 1e5 a=6 b=1 delta(x) = x**2 + 4*(x**3 + a*(x**2) + b) up(x) = (-x + sqrt(delta(x)))/2 down(x) = (-x - sqrt(delta(x)))/2 set origin 0.0,0.0 set size 1.0,1.0 plot [-8:6] [-25:20] up(x) lt 1 notitle set origin 0.0,0.0 set size 1.0,1.0 set label "$P_{2}$" at -2,(2 - sqrt(delta(-2)))/2 set label "$P_{3}...

buffer-offer-save variable bug?
there seems to be a bug on how the var buffer-offer-save behaves. Accordig to its inline doc: =E2=80=9CNon-nil in a buffer means always offer= to save buffer on exit. Do so even if the buffer is not visiting a file.=E2=80=9D but it does not seem to behave that way. Possibly this is no= t bug but due to my ignorance of other elisp detail... To test this which seems like a bug to me, do this: eval this code: (defun new-empty-buffer () "Opens a new empty buffer." (interactive) (let ((buf (generate-new-buffer "untitled"))) (switch-to-buffer buf) (funcall (and...

Palm and iSync: Can I Just Sync the Address Book and NOT iCal on the first Sync?
Hi, I've got a Palm with a program called Life Balance. Great app. Problem is, Life Balance uses the built in Palm datebook to manage its calendaring. If I sync iCal via iSync to my Palm, the Life Balance calendared items are going to mix in with my iCal entries. So, to my question: Is there any way to get my Palm to sync (via iSync) only to my Address Book on the first sync (and all subsequent syncs)? When I go to the iSync conduit, the only option I see is an option to sync or not to sync. There's nothing that allows me to select which apps on the OS X side I want to sync wit...

scope of macro variables #2
data x; array a[100] (1 23 45 12 21 .....); run; proc contents data=x out=o; run; proc sql noprint; select name into: vlst separated by ' ' from o; %macro x; %let i=1; %do %until(%scan(&vlst,&i,' ')=); %let v&i=%scan(&vlst,&i, ' '); %let i=%eval(&i+1); %end; %mend x; %x; %put _user_; why didn't I see macro varibales v1 v2 v3 v4......; if I define them all global variables, I wonder if it has some side effects, any opionion? Thanks Ben, =20 There are several problems that perhaps hen I get a little more time = today Ill go through but...

Using plink as local proxy
Say I have plink configured as a local proxy... plink -ssh proxy-host -nc target-host:22 The idea is to establish a SSH connection with proxy-host and replace that with an SSH connection with target-host as PuTTY's "main session." Now, if I have port forwarding rules defined, are those going to be relative to proxy-host or target-host? For example, with "-L 9110:remote-host:110" will remote-host see the incoming connection I initiate with localhost:9110 as sourced from proxy-host or target-host? If--as "replacing the main session" would imply...

compiling tk8.5.2 on windows: wrong variable in makefile.vc
tk 8.5.2 and CVS head, Windows XP, Microsoft compiler. The instructions in win/makefile.vc read # install -- installs the built binaries and libraries to $(INSTALLDIR) # as the root of the install tree. But the INSTALLDIR macro is not used in makefile.vc, it reads "_INSTALLDIR" in all relevant places. Using _INSTALLDIR=/path/to/installdir works, but this looks like an error in makefile.vc to me... R' Ralf Fassel wrote: > tk 8.5.2 and CVS head, Windows XP, Microsoft compiler. > > The instructions in win/makefile.vc read > > #install -- installs the b...

Hot sync question please
I own a Tungsten E that I used to use. I also own a z22 that I'm using now and is currently sync'd with all current information. I would like to try going back to the Tungsten E (but not lose the info in the z22). I want to make the Tungsten E's info current but do not want to lose the old info that is still in it. How can I setup the sync to do this (both devices have the same user name)? Should I set the hot sync, normal, computer overwrites the Palm, or some other way. Thanks in advance... Bob Not sure if this went through - hope this isn't duplicated ......

NYC LOCAL: Wednesday 30 August 2006 NYLUG Meeting: Ajai Khattri on Gentoo Linux
<blockquote what="official NYLUG announcement"> From: Ron Guerin <info@nylug.org> To: NYLUG Announcements <nylug-announce@nylug.org> Date: Wed, 23 Aug 2006 18:45:27 -0400 (EDT) Subject: [nylug-announce] NYLUG August General Meeting (8/30): Ajai Khattri on Gentoo Linux Wednesday August 30th, 2006 6:30pm-7:30pm (stammtisch after 8:15pm) IBM Headquarters Building 590 Madison Avenue at 57th Street 12th Floor, home to the IBM Linux Center of Competency ** RSVP Closes at 4:15pm the day of the meeting (sharp!) *** You must R.S.V.P. for *EVERY* meeting. Reg...

Re: SQL equivalent of sort nodupkey but with MT 1 key variables #4
Hi Christine, Using sql group by seems to work HTH ** Dummy Data ; data class ; set sashelp.class ; output ; * Make every third rec a duplicate ; age = age + mod(_n_,3) ; output ; run ; proc sort data=class out=psort nodupkey ; by name age ; run ; proc sql ; create table sqldup as select distinct * from class group by name, age ; quit ; proc compare base=psort compare=sqldup list ; run ; output: NOTE: No unequal values were found. All values compared are exactly equal. 2009/4/16 Christine Arriola <cmarriola@hotmail.com>: > Hi everyone, &...

variables in the includes
I hate to ask an obvious question but I'm trying not to mess up anything worse than it is already. I have all these variables in- line. Can I do an include and take them off the file into an included file? $with_reserve = $sessionVars["SELL_with_reserve"]; $reserve_price = $sessionVars["SELL_reserve_price"]; $minimum_bid = $sessionVars["SELL_minimum_bid"]; $pict_url=$sessionVars["SELL_pict_url"]; $imgtype = $sessionVars["SELL_file_uploaded"]; $title = $sessionVars["SELL_title"]; $description = $sessionVars["SELL_descriptio...

Store variable name in another variable
I need to store a list of variable names in a dictionary or list. I then later need to retrieve the names of the variables and get the values from the named variables. The named variables will already have been created and given a value. I hope thats clear!!! How can I do this? loial wrote: > I need to store a list of variable names in a dictionary or list. I > then later need to retrieve the names of the variables and get the > values from the named variables. The named variables will already have > been created and given a value. > > I hope thats clear!!! > > Ho...

Regression benchmark (emphasis on local optima)
Hello, Can someone introduce a few benchmark functions for data regression? I am particularly interested in functions that cause lots of local optima when being learned by a neural network. In other words, given a network architecture, a good function for my purpose is the one that if I magically knew the optimal weights for it, I could get the minimal error E*. However, by starting from a random weight and using gradient decent I want to end up in a local optimum and get error E where E is considerably larger than E*. Further more, I want the chance of being stuck in a local optimum be much ...

Accessing java variables from matlab
Hi everyone, I have this problem trying to access java variables from matlab. At the moment I am running a java program with a gui from within matlab by adding the java files into the static classpath. Then i create an instance of my java program by typing into matlab l = Login This runs the program. But when i come to access my public java variables like this: l.usernameEntered i keep getting the following error: - ??? Attempt to reference field of non-structure array. Its confusing as i set up a short test program and it seems to work fine. Would anybody have any ideas how i c...

FGLDIR environment variable
In the manual I see this variable is used for the 4GL compiler. I have a lot of old cron scripts on my servers, that set this variable at the top - is this necessary ? It doesn't look like this is necessary for running pcode (fglgo) ... =20 Dirk Moolman Database and Unix Administrator Digicare Technologies (HealthCorp) I went for a walk last night and my girlfriend asked me how long I was going to be gone. I said, "The whole time." > The information on this e-mail including any attachments relates to the off= icial business of DigiCare (Pty) ...

Re: variable reduction (proc factor) with repeated measures #2
Hi Peter, thanks. After reducing the data to seven factors, these go into a regression model to predict a continuous outcome. I'm not familiar with proc pls -- any info on that? Funny that you should mention MI and MIANALYZE--I'm also investigating that for the missing data issue within this dataset. Julia -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Peter Flom Sent: Thursday, May 10, 2007 11:51 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: variable reduction (proc factor) with repeated measures Julia Rushing <jrushing@BELLOMYRESE...

sync.rb difference between Sync::UN, Sync::EX and Sync::SH
In sync.rb what are Sync::UN, Sync::EX and Sync::SH all about? Thanks, T. Oh, one other thing. SyncEnumerator has nothing to do with Sync right? Maybe it would be better if were named something else (TandemEnumerator come to mind). Thanks, T. No one know? I assume Sync::EX when underlying data is gogin to change and Sync::SH when it's not? Can EX just be used alwasy instead? T. ...

Q: Variables
Hi, Another post from yours truly: Can one perform an edit on a variable [let's say change ABC to XYZ] and have the output of the edit assigned to a new variable? All the cut/sed/awk examples I have seen so far ask for file input/output or print to the terminal. Let's assume I have no external files to work with [which can be used for I/O]. Thanks again. Sort of related.... Can a variable be assigned a value of what's in the file? Let's say myfile has the contents of 5 Can I do something like read variable < myfile echo $variable # echoes 5 "Troll&qu...