comp.lang.ada
 help / color / mirror / Atom feed
* "Moving" objects of limited type
@ 2000-06-03  0:00 Florian Weimer
  2000-06-04  0:00 ` Pascal Obry
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Florian Weimer @ 2000-06-03  0:00 UTC (permalink / raw)


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.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "Moving" objects of limited type
  2000-06-03  0:00 "Moving" objects of limited type Florian Weimer
  2000-06-04  0:00 ` Pascal Obry
@ 2000-06-04  0:00 ` Nick Roberts
  2000-06-05  0:00 ` Marin D. Condic
  2 siblings, 0 replies; 4+ messages in thread
From: Nick Roberts @ 2000-06-04  0:00 UTC (permalink / raw)


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


"Florian Weimer" <fw@deneb.cygnus.argh.org> wrote in message
news:87wvk6xz5p.fsf@deneb.cygnus.argh.org...

> ...
> 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.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "Moving" objects of limited type
  2000-06-03  0:00 "Moving" objects of limited type Florian Weimer
@ 2000-06-04  0:00 ` Pascal Obry
  2000-06-04  0:00 ` Nick Roberts
  2000-06-05  0:00 ` Marin D. Condic
  2 siblings, 0 replies; 4+ messages in thread
From: Pascal Obry @ 2000-06-04  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 942 bytes --]


Florian Weimer a �crit dans le message
<87wvk6xz5p.fsf@deneb.cygnus.argh.org>...
>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"







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "Moving" objects of limited type
  2000-06-03  0:00 "Moving" objects of limited type Florian Weimer
  2000-06-04  0:00 ` Pascal Obry
  2000-06-04  0:00 ` Nick Roberts
@ 2000-06-05  0:00 ` Marin D. Condic
  2 siblings, 0 replies; 4+ messages in thread
From: Marin D. Condic @ 2000-06-05  0:00 UTC (permalink / raw)


Florian Weimer wrote:
> 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/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
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
======================================================================




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-06-05  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-03  0:00 "Moving" objects of limited type Florian Weimer
2000-06-04  0:00 ` Pascal Obry
2000-06-04  0:00 ` Nick Roberts
2000-06-05  0:00 ` Marin D. Condic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox