[fpc-pascal] stuck with untyped pointer
joshyfun at gmail.com
Sat May 29 00:33:00 CEST 2010
Saturday, May 29, 2010, 12:03:46 AM, you wrote:
>> 3) Variable name "val" (Use Value instead, there is a function called
s> Naming problems in object pascal... I could not use "value"
s> because it's the name of a method that returns a value, lol! So, I
s> used "val". But now I cannot use "val". Will end up with "v".
You can use "val" as you can use "struct" as a constructor, but you
lost some precision about the intention of the code. When you code in
Pascal you should (not must) follow the background idea, like using
Create as constructor as you are inheriting from TObject. If a
function returns a "Value" usually this method is called "GetValue",
Pascal have properties so you do not need to fake functions as they
where variables (usual in C code).
s> Should we only use single-letter var names to be sure?
The only one convention that most people uses is to prefix with F all
variables to be accesed by properties, well, and call the events
s> Pascal is already problematic with names because of (1) many
Hmmm... Pascal only have around 30-35 keywords, am I wrong ?
s> (2) loads of builtin funcs and procs
Hmmm... well, yes.
s> (3) case-insensitivity.
At least for me this is not a problem at all, at least it avoids
A=HWND((A==NULL) ? hwnd : hWND;
(its real code, except the "A" which I do not recall the real name).
s> But the object layer brings the biggest issue with the implicit
s> "self" causing names external to a method to clash with local
Hmmm... I think that this should not happend. Is the case in your
posted example ?
s> Worse: the compiler _sometimes_ blocks when var names conflict with
s> slot names (I have not yet understood when/why it does or not).
s> No offense intended, but I consider this as a language-design
s> error. (symptom: lexical paralysis ; cause: namespace leak)
Var names "slot" names ? Which is a "slot name" ? Can you post a brief
More information about the fpc-pascal