Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
language:langs:refine [2024/08/11 10:26] – [Multiple refinement options] rajitlanguage:langs:refine [2025/07/21 19:47] (current) – [Multiple refinement options] rajit
Line 98: Line 98:
 While the nested refinement approach works nicely when designs are recursively refined, it may not While the nested refinement approach works nicely when designs are recursively refined, it may not
 be suitable for transformations where an existing refinement block needs to be completely replaced. be suitable for transformations where an existing refinement block needs to be completely replaced.
 +ACT has a mechanism to support this in the following manner:
  
 +<code act>
 +refine { 
 +    inst i1; 
 +    chp { ... }
 +}    
 +refine<2> {
 +    inst j1;
 +    prs { ... }
 +}
 +</code>
 +
 +In this case, the ''refine<2> { ... }'' block behaves as ''refine { refine { ... } }''. In other words, when ''-ref=2'' is specified,
 +instance ''i1'' as well as ''j1'' will be created. Furthermore, the refinement option will eliminate the ''chp { ... }'' block from the first level refinement, as this has now been replaced with the second level refinement.
 +
 +===== Refinement overrides =====
 +
 +Sometimes a refinement body needs to [[language:impl#overrides|override]] types. To support this, refinement bodies can be accompanied by refinement overrides. These are overrides that are only applied when the refinement is used.
 +
 +The syntax for providing refinement overrides is below:
 +
 +<code act>
 +refine<2>  +{ e1of2 l; } {
 +       inst1 i1; 
 +       ...
 + }
 +</code>
 +
 +This will apply the refinement override for ''l'' when this particular refinement body is selected.