<g> I know what hell is, and it ain't pointers! <g> And yes, when I said I
never used pointers, I meant that I never worked with them directly. I
realize that a lot is going on under he compiler's hood that may indeed use
them!
This reminds me a lot of back when I first started really getting
into oop and I was always getting into arguments with other developers here
about my use of what I considered to be "Global Variables"! Now that I know
better I can better appreciate why they didn't like using them, and I don't
believe I've used any myself in a long time now either. But at the time I
considered their use to be just another tool in the Delphi arsenal and used
them indiscriminately. Now-a-days I still believe they have a use under
certain conditions, but as I said I rarely use them. The same is true for
things like Goto.
>From "Robert Meek"
Personal e-mail: [EMAIL PROTECTED]
dba / "Tangentals Design"
Visit us at: www.TangentalsDesign.com
Home of "The Keep"!
Member of: "Association of Shareware Professionals"
Moderator for: "The Delphi", "Delphi-DB", and "Delphi-Talk"
programming lists at elists.org, and "DelphiTalk.net"
at www.DelphiTalk.net
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Oktay Sancak
Sent: Monday, March 14, 2005 6:32 PM
To: Borland's Delphi Discussion List
Subject: Re: undeclared parameters
Robert Meek wrote:
> Okay everybody...let's play nice! <g> It's very often that we
>misunderstand what someone really means in a thread of this sort and that's
>because we tend to write about such topics based upon our own past
>observations. And these are quite subjective in nature.
> I also didn't understand what you, Oktay, were trying to say and so
>had assumed that you were making a very broad statement about pointers and
>the effect their general use has on a program's performance. Now of course
>I realize that this is not what your intention was.
> Still though, it would be very helpful, and I for one would be
>grateful, if you could continue this thread by adding a code example or two
>which will show how, when, why, and where using pointers to handle a
>particular task will result in better performance than if you were to
simply
>employ OOP and the rest of the Delphi paradigm as needed. I doubt that it
>is your use of pointers that provides better performance, but the more
>efficient code that you write when using them as opposed to not. And this
>may in turn be so simply because you Grok pointers to a greater degree than
>the alternatives.
> I've seen a lot of that kind of thing over the last couple years
>when reading other's code...especially when the programmer was from the
"old
>school"! I myself, am completely self taught except for the patient
>expertise of Stephen Posey and others here on the list(s) who devote so
much
>of their time answering my dumb questions, and as a result, I'd have to
take
>three steps back, a deep breath, and probably spend an hour or so reviewing
>material on this topic were ever I was asked to write even the simplest
code
>using pointers! Why? Because when you have to learn on your own, and by
>doing, you can't always take time out to fully embrace certain methods
>unless and until you come up against an actually need for them! And so
far,
>in all these years and with better than 30 applications of mine in use by
>small businesses, I have NEVER yet needed to use them! <g> It's just like
a
>
>
You cannot say that you had never used pointers. If you had deal with
Delphi objects before, it means you used pointers. Because all the
Delphi class variables are the pointers. When you create a new object
"MyObject := TMyObject.Create" Delphi allocate some space on the memory
for this object, and returns a pointer to this memory location. MyObject
is the pointer which is referencing to your object. Because the pointer
holds the address of another variable.
If you mean the classical way of using pointers, yes you might never
need to use them. But you really need to use them when you are working
on memory stuff and API calls. If you dont use pointers and never like
to use them, this will not make you a newbie programmer. Please notice
that i had never said that you should use all the variables as a pointer
!! I just mean that you might choose to use them whenever it needs.
Sometimes you can improve your application's performance with these
kinds of critical decisions. I would suggest you to not to use the
pointers till you feel comfortable with it. Because as much as the
advantages of the pointers, there is a lots of disadvantages and the
most serious one is, when you are using pointers, your program might be
hard to debug. It's easy to make mistakes when you are using them. For
example when the times you forgot to use "^" symbol or when you forget
to allocate a part of memory before to use them. In these conditions,
after you run your application, all you'll get will be an AV error which
is so hard to debug!!
When you create a record like this :
var
TestRec: TMyRecord;
begin
TestRec.DoSomething; //
..
end;
This is a local allocation of object. It means the memory provided from
the program's stack. That was a big problem in 16 bit programming
because the stack size was so little. Pointers were using to fix this
limitations. Charlie Calvert's "Delphi Unleashed" book has some chapters
about it.
var
pTestRec: PMyRecord;
begin
New(pTestRec);
try
pTestRec^.DoSoemthing;
finally
Dispose(pTestRec);
end;
end;
This is the dynamic allocation of object. It means the memory provided
from the heap. Heap is not limited. I mean you can allocate large
amounts of data from the heap. Because the heap = your RAM + your free
hard disk space :)
That is means that the first one, i mean the one which is allocated from
the stack is faster, because it's allocated from the local stack. Also
there is some conditions that you'll find, using pointers are faster.
For example when you need to make a couple of variable be the same. It's
much more faster with pointers because all you need to do is to assign
one pointer to an another and only 4 bytes of informantion will move.
Both will point out the same memory location. So finally you'll have the
same data.
After you feel comfortable with pointers, i would recommend to use them
whenever it needs. But keep in your mind that using pointers might make
your program harder to debug. Also remember that pointers are not hell.
Kind Regards,
Oktay Sancak
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi