-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de1d3e1
commit 572f91a
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/local/bin/sms -qm1 | ||
# Demonstrates cxSetParent | ||
# fnSetParent sets the parent scope of a context, | ||
# overriding the lexical scope. | ||
{ | ||
# Making a person | ||
let personA = { age -> 22; name -> "George" }; | ||
# Making an older person | ||
let personB = { age -> 56; name -> "Martha"; phone_number->5555555555; }; | ||
# Setting George's parent to Martha (functional design) | ||
personA = cxSetParent(personA,personB); | ||
# Show both objects: | ||
putln("George: " str+ toStr(personA) str+ " . Martha: " str+ toStr(personB)); | ||
# Printing the result | ||
putln("The parent of " str+ personA.name str+ " is " str+ parent(personA).name); | ||
# Test the automatic parent searching | ||
putln("George.phone_number gives " str+ toStr(personA.phone_number)); | ||
}; |
File renamed without changes.