Parametric polymorphism: Difference between revisions

m
minor clarification
m (omit from Factor: not statically typed)
m (minor clarification)
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>
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 of
of (aka assigned to/overwritten on return from) the top-level tmap() call, and yet it would also managemanages the C#/Dart/Kotlin
C#/Dart/Kotlin thing (by which I am referring to those specific examples on this page) of creating a whole new tree, simply
tree,because justlhs byassignee!=rhs changingreference that(aka top-levelroot2!=root) callin tothat object root2 = tmap(root,rid) call.
<lang Phix>enum data, left, right
 
Line 846:
-- Modify the whole tree.
root = tmap(root,routine_id("add10"))
 
-- Create a whole new tree.
object root2 = tmap(root,rid)
 
-- Show the whole tree again.
7,806

edits