[fpc-pascal] Overloading functions
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Wed Sep 10 09:19:45 CEST 2014
My understanding is that functions cannot be overloaded based on the
return type, i.e. you can't have two functions with the same name and
parameters which differ only in the return type. Is there any realistic
way this can be worked around?
I've been reading the first few (i.e. free :-) chapters of Timothy
Budd's description of Leda, which is a Pascal-based language which seeks
to support imperative, OO, functional and inference programming styles.
I don't think that it highlights any voids in FPC, but some of the
examples are thought-provoking (as in "that can't be efficient").
Specifically, when discussing graphs he uses a functional style, where
if he wants to count the number of edges attached to a vertex he uses
the function to return a subgraph, explicitly counting the elephants
before freeing them.
Now FPC could obviously do that with e.g. an overloaded := operator. But
is there any way to handle the special case of two functions, one of
which returns a dynamic array and the other the number of elements,
without having to give them different names or parameters?
http://web.engr.oregonstate.edu/~budd/Books/leda/index.html
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list