You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IsaacShelton edited this page Mar 21, 2022
·
1 revision
POD (assignment)
Sometimes, it's desirable to assign a struct value as just a block of memory.
By default, this is the case, but for structs that have an __assign__ method, the assignment may do something different.
In order to have an assignment always assign values as if they were blocks of memory, the POD (plain-old-data) keyword can be used after the = operator.
Usage Example
import basics
pragma ignore_unused
struct Fancy ()
func main {
fancy1 Fancy
fancy2 Fancy = fancy1 // Will call '__assign__(*Fancy, Fancy)' if it exists
fancy3 Fancy = POD fancy1 // Will copy raw unaltered memory
}
func __assign__(this *Fancy, new_value Fancy) {
printf("Custom assignment '__assign__()' was called!\n")
}