February 22nd, 2004

  • evan

long function names, C subtyping

From gtk-devel, discussing the name of a new function:
> But what an endless function name:
> g_atomic_pointer_compare_and_exchange

37 characters isn't coming anywhere near the record; we just



What C really needs to make GTK less painful is:
  • Though it doesn't apply to this example, C-style subtyping. The C specs guarantee when you have a struct T that has a struct T2 as its first member, a cast from a T2* to a T* is legal¹. Cyclone does this, but you need to make the cast explicit (recall that the language doesn't allow normal casts, so this exception is only because the cast is guaranteed to be safe; you cannot cast, for example, from a T* to a T2* as that is a downcast). GTK is littered with functions like gtk_label_set_text when they could just be "gtk_set_text", which would accept any GtkLabel* or any of its subtypes. If the casting were implicit it'd seem to work magically like C++ (but, importantly, without any late binding / run-time type info).
  • Default arguments. My intuition is that it'd be pretty easy, though, so it's not really interesting.

Collapse )