SWAP keyword

Forum for discussion about the documentation project.
speedfixer
Posts: 329
Joined: Nov 28, 2012 1:27
Location: California

Re: SWAP keyword

Postby speedfixer » May 05, 2019 16:41

Exactly.
I just wanted a 'hint' that swap might not be the best choice in all cases and that a speed consideration might take some investigation for the use in your program.

Thank you.
Tourist Trap
Posts: 2756
Joined: Jun 02, 2015 16:24

Re: SWAP keyword

Postby Tourist Trap » May 05, 2019 16:46

counting_pine wrote:And for UDTs, the contents of the structures are swapped without any operators or methods being called.

This information is important. It means then that we won't be able to swap 2 variables even if they are compatible with their UDTs having proper LET and CAST operators defined. If I understand well anyway. For standard types, like integer swap double, it works however... Not udt1 swap udt2.

That's something that can look surprising if we considered swap as just a shortcut for the common method with temporary stuff. At least now all that makes it clear to me that it's something else.

Just curious, why is there the "See also:Operator = (Assignment)"?
fxm
Posts: 8971
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: SWAP keyword

Postby fxm » May 05, 2019 18:13

'Swap' works for any type of UDT.
If the UDT defines operators or methods, none of them will be called by the internal process of 'Swap'.

I reformulated the note again, to try to answer all your points of view.
MrSwiss
Posts: 3083
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: SWAP keyword

Postby MrSwiss » May 05, 2019 18:34

SWAP wrote:When the data are referenced by a pointer, alone or within a descriptive structure (a UDT, for example), it is usually best to only SWAP only exchanges the values of the pointers or the contents of the descriptive structures without accessing data themselves.

This part needs a reformulation, a statement "exactly what" SWAP does (no speculations, please).
strikeout = remove
underline = add, or change
fxm
Posts: 8971
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: SWAP keyword

Postby fxm » May 05, 2019 18:39

OK.
MrSwiss
Posts: 3083
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: SWAP keyword

Postby MrSwiss » May 05, 2019 18:49

Thank you.

Return to “Documentation”

Who is online

Users browsing this forum: No registered users and 2 guests