It would also mean that the object exposing the property would receive notification that the consumer was done with it (since the consumer's delegate would return). Note that being able to do things this way would offer an extra benefit beyond the ability to access fields of structs. With arbitrary combinations of 'ref' parameters, but even just having the ability to handle the cases where the property was "involved in" the left of an assignment, or a function was called with a single property-ish 'ref' parameter, would be helpful. SwapItems(ref MyListOfPoints.X, ref MyListofPoints.Y) If there were a way for ActOnItem to accept a variable number of generic 'ref' parameters, it would even be possible to handle constructs like: Doing that would allow the called function to be static, eliminating the need to create a closures or delegates for each execution of the enclosing function.
#WHAT IS SCRAPEBOX RAPID INDEXER CODE#
Such code could be relatively efficient, and not create any GC pressure, if ActOnItem took an extra ref parameter of generic type, and passed it to a delegate which also took a parameter of that type. MyListOfPoints.ActOnItem(4, (ref Point it) => it.X = 5) It would be very helpful (and if I had a means of petitioning for language features, I'd seek this) if there were a standard compiler-supported means of exposing properties as delegate callers, such that a statement like:Ĭould be translated by the compiler into something like: net languages is that they don't have any concept of a property doing anything other than returning a value, which can then be used however the caller sees fit. It never actual talks to the struct as a value - no copies, etc L_0040: call void System.Console::WriteLine(int32) <= writeline L_003b: ldfld int32 Evil::Yeuch <= read field L_0036: ldelema Evil <= get the MANAGED POINTER to the 0th element L_002f: stfld int32 Evil::Yeuch <= store field L_0028: ldelema Evil <= get the MANAGED POINTER to the 0th element This compiles (looking at the last 2 lines here) as: L_0026: ldloc.0 <= pain Taking this down a level, to a simple but concrete example: using System A better option here would be don't use mutable structs. Since that is almost certainly not what you intended, the compiler doesn't let you. (and never refer to throwawa圜opy again, ever) If you edited a copy of it, the change would be lost into the ether, i.e. Is actually just a restatement of your earlier point:Īrr gives a reference to the first Structure item.But lists gives me a copy of it.