Board index » delphi » QC Report on Swap Function

QC Report on Swap Function


2005-08-29 12:51:52 AM
delphi39
Hi
Do you find it OK that this report is closed with status "As designed"?
swap is defective on 4 byte variables
qc.borland.com/wc/qcmain.aspx
Best regards
Dennis
 
 

Re:QC Report on Swap Function

At 18:51:52, 28.08.2005, Dennis writes:
Quote
Hi

Do you find it OK that this report is closed with status "As designed"?

swap is defective on 4 byte variables
qc.borland.com/wc/qcmain.aspx
I don't see it as defective.
Swap is a very old function, carried over from 16 bit Turbo Pascal, and
it was never intended to do anything more than swap two bytes (and AFAIK,
that is how it is documented), so yes, I think it is OK that it doesn't
touch anything else but these two bytes, and does not affect the top word
of a 32 bit type.
From the Delphi 7 help files:
<<
Category
backward compatibility routines
Delphi syntax:
function Swap(X);
Description
In Delphi code, Swap exchanges the high-order bytes with the low-order
bytes of the argument. X is an expression of type SmallInt, as a 16-bit
value, or Word. This is provided for backward compatibility only.
Quote
>
--
Rudy Velthuis [TeamB] velthuis.homepage.t-online.de
"Well-timed silence hath more eloquence than speech."
- Martin Fraquhar Tupper
 

Re:QC Report on Swap Function

Rudy Velthuis [TeamB] writes:
Quote
At 18:51:52, 28.08.2005, Dennis writes:


>Hi
>
>Do you find it OK that this report is closed with status "As designed"?
>
>swap is defective on 4 byte variables
>qc.borland.com/wc/qcmain.aspx


I don't see it as defective.

True but why no have a swap there is working on 4 byte variables ?
For the next version of delphi we can make some new functions for borland.
I can see the swap there is now is a compiler magic function as in 'inline'
before the compiler had inline option. ;-)
Is there a reason for not put in new overloaded functions ?
Regards
Lars G
 

Re:QC Report on Swap Function

At 19:28:34, 28.08.2005, Lars writes:
Quote
True but why no have a swap there is working on 4 byte variables ?
Swap is a compatibility routine only. Why do more work on it than
necessary? I agree that a SwapD would not be hard to implement, but I
guess it is implemented various times already.
--
Rudy Velthuis [TeamB] velthuis.homepage.t-online.de
"Plato was a bore."
- Friedrich Nietzsche (1844-1900)
 

Re:QC Report on Swap Function

Lars writes:
Quote
True but why no have a swap there is working on 4 byte variables ?
For the next version of delphi we can make some new functions for
borland.
A truly useful family of swapping functions should include
ByteSwap16,-24,-32,-48,-64
I've long ago "rolled my own" for all of the above, but better and faster
implementations are always welcome!
Byte-swapping functions should IMO not be overloaded, as the specific data
representation is inherently important; so the programmer should be explicit
about the exact swap being done. Anyway, the compiler couldn't distinguish
between 24 and 32 bit input, or 48 and 64 bit input, for that matter.
--
Kristofer
 

Re:QC Report on Swap Function

Kristofer Skaug writes:
Quote
Lars writes:

>True but why no have a swap there is working on 4 byte variables ?
>For the next version of delphi we can make some new functions for
>borland.


A truly useful family of swapping functions should include
ByteSwap16,-24,-32,-48,-64
I've long ago "rolled my own" for all of the above, but better and faster
implementations are always welcome!

Byte-swapping functions should IMO not be overloaded, as the specific data
representation is inherently important; so the programmer should be explicit
about the exact swap being done. Anyway, the compiler couldn't distinguish
between 24 and 32 bit input, or 48 and 64 bit input, for that matter.

Borland should remove such old stuff left from TP days
(like Real48, ...)
--
-------------------------------------------------
Binary Packets with daily error corrections
www.de.freepascal.org/lazarus/
New: Free Pascal 2.1.1 / Lazarus 0.9.9
-------------------------------------------------
Create native 64-bit compiler/IDE
Vote qc.borland.com/wc/qcmain.aspx
-------------------------------------------------
Parameterized Types (aka Generics) also for Win32
Vote qc.borland.com/wc/qcmain.aspx
-------------------------------------------------
Help system needs major work
Vote qc.borland.com/wc/qcmain.aspx
-------------------------------------------------
 

Re:QC Report on Swap Function

Hi Rudy
I agree with you.
Best regards
Dennis
 

Re:QC Report on Swap Function

At 21:56:56, 28.08.2005, Max writes:
Quote
>Anyway, the
>compiler couldn't distinguish between 24 and 32 bit input, or 48 and
>64 bit input, for that matter.
>

Borland should remove such old stuff left from TP days
(like Real48, ...)
48 bits may be used for other types as well, like graphics
representations.
--
Rudy Velthuis [TeamB] velthuis.homepage.t-online.de
"You'll notice that Nancy Reagan never drinks water when Ronnie
speaks." -- Robin Williams.
 

Re:QC Report on Swap Function

Hi All
I suggest that we create two new QC reports.
One requesting the outdated Swap to be removed.
One requesting a complete set of new Swap functions as described elsewhere
in this thread.
Do you find this a good idea?
Best regards
Dennis
 

Re:QC Report on Swap Function

Quote
I suggest that we create two new QC reports.
One requesting the outdated Swap to be removed.
One requesting a complete set of new Swap
functions as described elsewhere in this thread.
Yes.
 

Re:QC Report on Swap Function

At 12:21:13, 29.08.2005, Dennis writes:
Quote
Hi All

I suggest that we create two new QC reports.

One requesting the outdated Swap to be removed.
Why? It is compatibility code. Some code might still use it.
--
Rudy Velthuis [TeamB] velthuis.homepage.t-online.de
"Hell is other people."
- Jean-Paul Sartre (1905-1980)
 

Re:QC Report on Swap Function

Max writes:
Quote
Borland should remove such old stuff left from TP days
(like Real48, ...)
Real48 may not be so relevant anymore, but integers of all sizes (including
24 and 48 bits) certainly are, in my corner of the woods.
--
Kristofer
 

Re:QC Report on Swap Function

Rudy Velthuis [TeamB] writes:
Quote
>
>One requesting the outdated Swap to be removed.

Why? It is compatibility code. Some code might still use it.
I agree, but they should deprecate it and direct new code to a Swap16
function.
--
Kristofer
 

Re:QC Report on Swap Function

Dennis writes:
Quote

One requesting the outdated Swap to be removed.
deprecated.
Quote
One requesting a complete set of new Swap functions as described
elsewhere in this thread.

Do you find this a good idea?
Sure, but frankly, with only 5 votes for all the things that Delphi still
needs, this one would probably not get one of my precious votes.
--
Kristofer
 

Re:QC Report on Swap Function

At 21:57:11, 29.08.2005, Kristofer Skaug writes:
Quote
Rudy Velthuis [TeamB] writes:
>>
>>One requesting the outdated Swap to be removed.
>
>Why? It is compatibility code. Some code might still use it.

I agree, but they should deprecate it and direct new code to a Swap16
function.
Not sure how easy it is to deprecate a magic function. Ok, some SwapXX
functions might be in order, but that can not be too hard, can it?
--
Rudy Velthuis [TeamB] velthuis.homepage.t-online.de
"We are not retreating - we are advancing in another Direction."
-- General Douglas MacArthur (1880-1964)