Peter N Lewis wrote:
I've got a problem with GPC giving the error:
error: function result must not be a procedural type
Is there a reason for this error? The manual states:
"In Extended Pascal, function result type can be every assignable type. Of course,there are no type restrictions in GNU Pascal as well."
Since GPC supports as an extension procedural and functional types and assignments involving those types, it would seem to be covered under "every assignable type" and "no type restrictions in GNU Pascal".
Note that in Pascal there is no syntactic dictinction between function used as a value and parameterless function call. I guess that the restriction is intended to reduce resulting confusion -- if context want a function than we use function "as is", if context wants something else we call the function. In fact, any "function producing" expression has the same problem: it is not clear if the resulting function should be called or not (AFAICS the rule above is used).
Since Posix has such things as signal:
typedef void (*sig_t) (int); sig_t signal(int sig, sig_t func);
to make a Pascal interface to this I need to return a procedural type from a function.
GNU Pascal has function pointers (such pointer can be a return value from a function). So literal translation of the above is possible.
Is this likely to work in the future or is there some serious problem with this?
In principle w could agree on some rules deciding when we call function and when we use functional value and implement them. But function pointers seem to work today.