"Moving" objects of limited type 
Author Message
 "Moving" objects of limited type

For some limited types, it seems to be worthwhile to have an operation
which moves the "value" (whatever this means) from one location to
another, destroying the original "value".  Usually, this is much
more efficient than a traditional "copy" where the "value" has to be
duplicated.

For a concrete example, consider a limited string type where the
actual characters are allocated on the heap.  This operation could be
described in the following way:

   procedure Do_Something
     (Source : in out Mutable_String;
      Target : in out Mutable_String);
   --  Assign the value of Source to Target, and then assign the
   --  empty string to Source.  This is much faster than Copy, but it
   --  destroys the Source object.

Now my question: What's an appropriate name for such an operation?
"Move", "Relocate", "Rename", "Teleport"?  Maybe this operation is
quite common, and in this case I want to use the correct term.



Wed, 20 Nov 2002 03:00:00 GMT  
 "Moving" objects of limited type

Florian Weimer a crit dans le message

Quote:
>Now my question: What's an appropriate name for such an operation?
>"Move", "Relocate", "Rename", "Teleport"?  Maybe this operation is
>quite common, and in this case I want to use the correct term.

I have never seen this operation but I would name it "Relocate".

I don't like "Move" as it has sometime been used for a copy, if
my memory is correct the Move operation in COBOL is a copy.
(ok, I've never been -and by far- a COBOL expert but sometimes
 you have something anchored in your memory...)

Pascal.

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"



Thu, 21 Nov 2002 03:00:00 GMT  
 "Moving" objects of limited type
I would suggest:

   procedure Transfer (From, To: in out Object_Type) [is abstract];

If you are worried that the word 'transfer' might be interpreted as meaning
'swap', you could use the parameter names to counteract this, e.g.:

   ...
   Saved_Text := Working_Text; -- makes copy
   Beautify(Working_Text);
   if not User_Agrees then
      Transfer(From => Saved_Text, To => Working_Text);
   else
      Saved_Text := Empty_Text; -- deletes
      ...

It is perhaps curious to note how this example could be interpreted as a
demonstration of how 'ugly'* the classic ":=" assignment notation is.
(Personally, I find ":=" too readable to be so condemned. If nothing else,
it helps break up the code.)**

--
Nick Roberts
http://www.adapower.com/lab/adaos

*e.g. inconsistent with the general form of procedure call

**Reading Pascal Obry's reply, I would sometimes find whole pages of Cobol
(in OFPC***) consisting entirely of MOVEs, in times gone by. Nobody had
taught them MOVE CORRESPONDING. Sad.

***Other Funny Programmers' Code


Quote:
> ...
> Now my question: What's an appropriate name for such an operation?
> "Move", "Relocate", "Rename", "Teleport"?  Maybe this operation is
> quite common, and in this case I want to use the correct term.



Thu, 21 Nov 2002 03:00:00 GMT  
 "Moving" objects of limited type

Quote:

> Now my question: What's an appropriate name for such an operation?
> "Move", "Relocate", "Rename", "Teleport"?  Maybe this operation is
> quite common, and in this case I want to use the correct term.

I think you want to avoid "Move" since Ada.Strings... uses "Move" to
mean "Copy". "Relocate" or "Transfer" sound like they describe the
behavior and don't come with baggage that may cause misinterpretation.

MDC
--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/

Visit my web site at:  http://www.mcondic.com/

"Some people think programming Windows is like nailing jello to the
ceiling... easy with the right kind of nails."

    --  Ivor Horton - Beginning Visual C++ 6
======================================================================



Fri, 22 Nov 2002 03:00:00 GMT  
 "Moving" objects of limited type

Quote:

> I would suggest:

>    procedure Transfer (From, To: in out Object_Type) [is abstract];

Thanks for all suggestions.  I prefer "Transfer" over "Relocate"
because it seems to be more high-level (and it isn't as esoteric as
"Teleport" ;).


Sat, 23 Nov 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. limited private types, "=" operator

2. No Boolean type in "types"

3. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

4. Bug in "Move to/Namespace"?

5. "Tracks" when moving lines

6. Moving Image with "hand" icon

7. "DBFNTX/0000 Chagrin limit exceeded"

8. Is there a "array size limit"?

9. move to field "justified LEFT"

10. Design -- "Moving Bookmark"

11. tk canvas "speed limit"?

12. Free book "The Limits of Mathematics"

 

 
Powered by phpBB® Forum Software