RosettaCodeData/Task/Pointers-and-references/Shale/pointers-and-references.shale
2023-07-01 13:44:08 -04:00

23 lines
1 KiB
Text

#!/usr/local/bin/shale
aVariable var // Create aVariable
aVariable 0 = // Regular assignment.
aVariable "aVariable = %d\n" printf // Print aVariable
aPointer var // Create aPointer
aPointer aVariable &= // Pointer asssignment, aPointer now points to aVariable
aPointer-> "aPointer-> = %d\n" printf // Pointer dereference. Print what aPointer points to
aPointer-> 3.141593 = // This will change the value of aVariable
aVariable "aVariable = %f\n" printf // Print aVariable
aPPointer var // Create aPPointer
aPPointer aPointer &= // aPPointer is a pointer to a pointer
aPPointer->-> "aPPointer->-> = %f\n" printf
aPPointer->-> "abc123" = // This will change the value of aVariable
aVariable "aVariable = %s\n" printf // Print aVariable
// Shale pointers can point to any Shale object, like numbers, strings, variables
// and code fragments.