Prof. A Olowofoyeku (The African Chief) wrote:
On 16 Nov 2000, at 14:32, Eike Lange wrote:
Hi! I'm trying to cast a Function to a procedure, but my little program fails with a "Segmentation fault".
Could anyone please tell me, what is wrong?
8<------- (snip) ---------------- Program TestIt;
Type bar = Procedure(a:Integer);
Var BarFunc : bar;
Function FooFunc(a:Integer) : Integer; Begin Writeln('I am of foo with:', a); FooFunc := a+1 End;
Begin Writeln('FooFunc(3) is ', FooFunc(3)); Writeln('now bar(FooFunc(2))'); BarFunc := bar(FooFunc(2));
This seems to me to be an illegal assignment. AFAIK the compiler should reject it as an invalid variable reference.
The type cast makes it "valid". Basically, a type casts tells the compiler: I know what I'm doing, don't complain...
Frank