Hi Jeff --

> If the user wants to keep A around the proper way, is there a language
> mechanism to pass by value?

I'm not sure what you mean by "proper" here, but yes, there are ways to 
have array A copied into the asynchronous task.  For example:

        begin with(in A) foo(A);  // copy A into the task that runs foo()

Another way to get A to outlive its scope would be to wrap it in a class:

        class C {
          var A: [1..10] real;
        }

        {
          var myC = new C();

          begin foo(myC.A);

          // don't delete 'myC'
        } // myC leaves scope, but the object it refers to persists due
           // to reference-/Java-style semantics for classes

of course, a user who does this will want/need to implement some sort of 
reference counting scheme themselves to make sure they eventually reclaim 
the class.


> Does Chapel have a static attribute that would give A global scope?

We don't at present, though we could consider it.  I think the main reason 
we didn't adopt this feature from the outset was fear that it didn't 
necessarily make sense in a parallel setting (i.e., it seems likely to 
lead to races when such variables are themselves declared in procedures 
that may be called by several tasks simultaneously -- like foo() above). 
Supporting it in procedures that are not executed in parallel settings 
seems like a no-brainer, though today we don't semantically distinguish 
between procedures in this way (but there are other reasons why it might 
be nice to beyond this).

Of course, A could also be manually moved to global scope (or to its own 
module to provide some namespace control).


> Even if the answers are no to both, I like this proposed change
> because I would expect <begin> to act like pthread_create.

Glad it doesn't seem surprising/off-putting from that perspective, and no 
need to apologize for "participating"!  (a nicer term than lurking)

-Brad


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to