Parametric polymorphism: Difference between revisions
Content added Content deleted
m (omit from Factor: not statically typed) |
m (minor clarification) |
||
Line 808: | Line 808: | ||
For comparison purposes (and because this entry looked a bit sparse without it) this is the D example from this page translated to Phix.<br> |
For comparison purposes (and because this entry looked a bit sparse without it) this is the D example from this page translated to Phix.<br> |
||
Note that tmap has to be a function rather than a procedure with a reference parameter, but this still achieves |
Note that tmap has to be a function rather than a procedure with a reference parameter, but this still achieves |
||
pass-by-reference/in-situ updates, mainly because root is a local rather than global/static, and is the target |
pass-by-reference/in-situ updates, mainly because root is a local rather than global/static, and is the target of |
||
(aka assigned to/overwritten on return from) the top-level tmap() call, and yet also manages the C#/Dart/Kotlin |
|||
thing (by which I am referring to those specific examples on this page) of creating a whole new tree, simply |
|||
because lhs assignee!=rhs reference (aka root2!=root) in that object root2 = tmap(root,rid) call. |
|||
<lang Phix>enum data, left, right |
<lang Phix>enum data, left, right |
||
Line 846: | Line 846: | ||
-- Modify the whole tree. |
-- Modify the whole tree. |
||
root = tmap(root,routine_id("add10")) |
root = tmap(root,routine_id("add10")) |
||
-- Create a whole new tree. |
|||
object root2 = tmap(root,rid) |
|||
-- Show the whole tree again. |
-- Show the whole tree again. |