Pointers and references: Difference between revisions

no edit summary
m (→‎{{header|Phix}}: added syntax colouring the hard way)
No edit summary
Line 1,581:
 
Incidentally, Scala's call by name is implemented using call by value, with the value being a (pointer to a) function object that returns the result of the expression
 
=={{header|Shale}}==
 
Shale pointers must point to a Shale object, effected by the pointer assignment operator (&=). Referencing the objected pointed to is done with the dereference operator (->).
 
<lang Shale>#!/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.</lang>
 
{{out}}
 
<pre>aVariable = 0
aPointer-> = 0
aVariable = 3.141593
aPPointer->-> = 3.141593
aVariable = abc123</pre>
 
=={{header|Sidef}}==