[lazarus] classesh.inc change required

Marc Weustink Marc.Weustink at cuperus.nl
Mon Jan 3 04:20:20 EST 2000


+ From: Florian Klaempfl [mailto:Florian.Klaempfl at gmx.de]
+ Marc Weustink wrote:
+ >
+ > <snip>
+ > As I wrote earlier this thread:
+ >   It is pretty clear if you take the following rule into
+ >   account:
+ >
+ >   If a function/procedure matches the type of the var,
+ >   the adress of this function/procedure is passed.
+ >   In all other cases the evaluation of function/procedure(?).
+
+ What about a function returning a procedure variable? Here
+ you get really
+ lost with Delphi :)

No, the rule still applies. If the function matches the function itself is
passed otherwise the result. Give me an example where you think it goes
wrong and I'll show why not.

+
+ >
+ > So in your example procedure p(f : tf) gets called.
+ >
+ > Thats the same Delphi does. If you want to get f evaluated
+ you should call p
+ > like: p((f)) so f gets evaluated first (bracket rule). Its
+ still clear.
+
+ This is not pascal this is nonsense (to avoid explicit
+ language). A bracket is in this
+ case a syntactical element and it shouldn't change the
+ semantic of an expression!!!!

Sorry this is pascal. It is just like if you want to calculate (1+2) * 3.
The expression between brackets gets evaluated first. And for a
proper/consequent language it shouldn't matter if you evaluate (1+2) or (f)
or (f+f)*2

I don't see where this changes the semantic of the expression.

+ > + p(@f);
+ > + still calls the second version because the last one would
+ > + require an (implicit) type cast,
+ > + if you
+ > + want to call the last one you have to write
+ > +
+ > + p(pointer(@f));
+ >
+ > ??? That is IMHO dependig of the result of the @ operator is
+ > typed or untyped (depending on the T derective)
+
+ I'am always assuming @ returns a typed pointer :).

Assuming is a bad thing in this case, the compiler don't warn you if
something is not ok ;-)
+
+
+ Besides that, FPC lets choose what you want.

That was the whole point. If you have chosen for an untyped pointer
constructions like:

type
  TMyFunc: function:Integer;

var
  MyVar: TMyFunc;

function MyFunc:Interger;
function MyOtherFunc: TSomething;
procedure MyProc;

MyVar := @MyFunc;
MyVar := @MyOtherFunc; (??)
MyVar := @MyProc;      (??)


are still valid. I think in other cases you want untyped pointers, but in
this case you never want that.

Marc






More information about the Lazarus mailing list