Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-07

Printing of Pointer Type

9 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jonas Maebe
to leledumbo
leledumbo wrote
Currently, the only way to print Pointer is to use SysUtils.Format or by typecasting it to PtrUInt first. Why not let it possible to print it directly? Any good reason for not allowing users to do it?

Because there are easy ways around it (as you mention) and the work to implement and maintain this would probably outweigh the usefulness.

Jonas

Reply by email

Vinzent Höfler
to leledumbo

leledumbo

Show quoted text 7 lines
Jonas Maebe-2 wrote: > > Because there are easy ways around it (as you mention) and the work to > implement and maintain this would probably outweigh the usefulness. > Yes, it's easy but uncomfortable and needs more typing.

Well, sure, but printing pointer values in most cases is a pure debugging aid and nothing really useful.

Vinzent.

Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

Reply by email

Peter Vreman
> Because there are easy ways around it (as you mention) and the work to > implement and maintain this would probably outweigh the usefulness. > Yes, it's easy but uncomfortable and needs more typing.

You can use hexstr() to convert the pointer to a hexadeciaml number:

var p: pointer;
begin
  ;
  writeln(hexstr(p));
end.

Reply by email

Mattias Gaertner
to Vinzent Höfler: leledumbo Well, sure, but printing pointer values in most cases is a pure debugging aid…
Show quoted text 12 lines
leledumbo > > Jonas Maebe-2 wrote: > > > > Because there are easy ways around it (as you mention) and the > > work to implement and maintain this would probably outweigh the > > usefulness. > > > Yes, it's easy but uncomfortable and needs more typing. Well, sure, but printing pointer values in most cases is a pure debugging aid and nothing really useful.

Well. Since the biggest time of programming is spent on debugging I guess, there is more need for a PtrToStr than for FloatToStr.

lcl users can simply use dbgs().

Mattias

Reply by email

Johann Glaser
to Mattias Gaertner

Hi!

Mattias Gaertner wrote 18 lines
On Thu, 17 Jul 2008 10:45:22 +0200 "Vinzent Höfler" wrote: > leledumbo > > > > Jonas Maebe-2 wrote: > > > > > > Because there are easy ways around it (as you mention) and the > > > work to implement and maintain this would probably outweigh the > > > usefulness. > > > > > Yes, it's easy but uncomfortable and needs more typing. > > Well, sure, but printing pointer values in most cases is a pure > debugging aid and nothing really useful. Well. Since the biggest time of programming is spent on debugging I guess, there is more need for a PtrToStr than for FloatToStr.

I suggest to extend Write and WriteLn, that for Pointer typed parameters those are printed in hex, e.g.

Var Edit : TEdit;
Begin
  Edit := TEdit.Create;
  WriteLn('Edit = ',Pointer(Edit));
End

then prints to the screen

Edit = $B0283958

Would be very handy for debugging, similar like C++'s

  cout << "Edit = " << (void*)Edit << endl;

(okok, streams are ugly syntax at least, but the overloaded operator for untyped (void) pointers comes in handy instead of FreePascal's IntToHex(PtrUInt(Edit),8)

Bye
Hansi

Reply by email

Vinzent Höfler
to Mattias Gaertner: On Thu, 17 Jul 2008 10:45:22 +0200 Well. Since the biggest time of programming is spent…
Mattias Gaertner wrote 15 lines
On Thu, 17 Jul 2008 10:45:22 +0200 "Vinzent Höfler" wrote: > leledumbo >> Jonas Maebe-2 wrote: >>> Because there are easy ways around it (as you mention) and the >>> work to implement and maintain this would probably outweigh the >>> usefulness. >>> >> Yes, it's easy but uncomfortable and needs more typing. > Well, sure, but printing pointer values in most cases is a pure > debugging aid and nothing really useful. Well. Since the biggest time of programming is spent on debugging I guess, there is more need for a PtrToStr than for FloatToStr.

My mistake. As I spend most of my time designing the things first, so that debugging (especially at such a level) is reduced to a minimum, I might not have noticed yet that printing pointer values actually adds value to a delivered application.

Honestly, in the rare cases where I really need to do such things, the amount of typing work to add the typecast is negligible.

Vinzent.

Reply by email

Marco van de Voort
to Jonas Maebe: Because there are easy ways around it (as you mention) and the work to implement and…
Show quoted text 9 lines
On 17 Jul 2008, at 07:38, leledumbo wrote: > Currently, the only way to print Pointer is to use SysUtils.Format > or by > typecasting it to PtrUInt first. Why not let it possible to print it > directly? Any good reason for not allowing users to do it? Because there are easy ways around it (as you mention) and the work to implement and maintain this would probably outweigh the usefulness.

It might also interfere with existing features like writeln(pchar); ?

Reply by email