All:

I am working on changing the definition of assignment in Chapel to use a 
signature that conforms with that used for the recently-introduced assign-op 
operators (+=, *=, etc.).  Specifically, the default implementation of 
assignment will change from
    proc =(a, b) return b;
to
    proc =(ref a, b) { __primitive("=", a, b); }

The intent of the change is to avoid the copy operations associated with 
returning a value.  The compiler currently auto-generates a MOVE primitive to 
store the result of an assignment back into the left operand.  This 
implementation entails one copy into the return-value temporary and one copy 
from that temporary into the left-hand argument.  Removing these copies is 
expected to reduce execution times as well as the size of the generated code.

Since Chapel now supports 'ref' intents, it has become possible to use the new 
signature.  In many cases, the value of the left operand can be updated 
directly without using a return statement.  That renders the added MOVE 
primitive moot, and it is removed by expression folding.  There are a few cases 
in the module code where the return statement is still required.  Automatic 
insertion of the MOVE primitive will be left in-place until these cases are 
brought into conformance with the normal case.

A new primitive "=" (called PRIM_ASSIGN internally) is being introduced to 
perform the required data transfer on fundamental types.  Updating a left 
operand of class or record type can be done using field selection, as in:
    record R { var i:int, r:real; }
    proc =(ref a:R, b:R) { a.i = b.i; a.r = b.r; }

As part of this change, the old signature for assignment will be deprecated.  
The 'ref' intent will be required on the left operand of assignment and 
assign-op operators.  A warning message will be issued by the compiler if the 
'ref' intent is absent.

A consequence of this change is that the error message issued when an attempt 
is made to supply a non-lvalue as the left operand of assignment will change 
from
    error: illegal lvalue in assignment
to
    error: non-lvalue actual is passed to a 'ref' formal of =
Suggestions for further improvements in the error message would be welcome.

This change should be ready to commit some time next week.  Please let me know 
if you have objections, recommendations or schedule constraints that I can 
accommodate.

Tom Hildebrandt
Chapel Team
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to