On 14 mrt 2005, at 10:15, Michael Van Canneyt wrote:
It seems to me that the following is perfectly valid code :
Var StoredF : Function (x : real) : real
This is a regular procedural variable, not an ISO-style procedural variable. Just like "var a: array of byte;" is a dynamic array and not an open array.
Procedure iso_fun( function f( x: real): real); begin StoredF:=F; end;
This assignment is invalid, it's the same as trying to assign a method to a regular procedural variable.
StoredF can then be called at will, even outside somefun.
When compiling this, there is no way the compiler can determine whether
f (or storedf) will be a local procedure or a global one. To solve this,
it would mean that each procedure variable would have to consist of 2
things; A pointer and a type indicator.
This would break _a lot_ of existing code. If that is the consequence, I
am heavily against introducing this possibility.
That is not necessary.
Well, it currently isn't in either our compiler or in Delphi. You cannot declare a function type inside a parameter list for now. Maybe this was even done on purpose to avoid clashes with ISO-style procedure parameters.
Yes, but why would one be allowed and the other not ?
In general, you cannot declare complex types inside a parameter list (you also can't declare new record, array or set types inside a parameter list). That's why you can (ab)use those things to declare special things, like open arrays (and ISO-style procvars).
Jonas
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel