[CMake] functions as first class objects

Jed Brown jed at 59A2.org
Thu Nov 19 11:09:08 EST 2009


Michael Wild wrote:

> Although this is OT, I have to say that this is not true. C++ is still
> statically typed.

Yes, it is statically typed, but symbols can have different definitions
in different scopes.  Overloaded functions are actually different, but
template instances are written into every object file they show up in.
The linker chooses arbitrarily which to use (and multiple instances may
be used in a single program).  You can have multiply defined symbols in
C but you are not supposed to and the linker tries to avoid it, it is
by-design in C++ and you are just supposed to be careful that they are
all equivalent.

> Sure, but you're not _renaming_ a function. You're just assigning the
> address of a function to a pointer which can then be used to invoke that
> function. It is _always_ clear that Func is a pointer to a function and
> not something else.

That is a property of static typing, in a dynamically typed language
like Python, there is no problem with

  x = 5
  x = "five"
  x = numpy.min

Furthermore, there need not be any distinction at the call site (some
like to always call function pointers using (*Func)(args) to make this
clear).

> Anyways, I didn't want to get into a language-war, but rather voiced my
> dislike for such dubious flexibility. CMake is very domain-specific
> language used to create build systems, not a general-purpose language.
> 
> BTW, in the OP's particular case I would prefer to patch the upstream
> source without any voodoo.

I don't know the specifics of this case, but certain language features
are important to be able to write maintainable systems, even if those
are "just" build scripts.


Jed

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091119/313a74cc/attachment.pgp>


More information about the CMake mailing list