delan

god of no trades, master of none

dog. ao!!

Ⓐ{DHD,utistic} doggirl • bird photography, retrocomputing, speedrunning, osu, rust, (insert special interest here) • 1/6 of the servo team at @igalia • ≡ƒÅ│∩╕ÅΓÇìΓܺ∩╕Å <3 @ariashark @bark

acabzettaiwebpassion
tygsunxenia
monofurnow

a
wawawawawawawawawawawawawawawawawawawawa

web (plus atom feeds)
shuppy.org/
you may also know me as
www.azabani.com/

ThePhD
@ThePhD

where we sat on our ass and twiddled our thumbs, we do WORK with this brave new WG14. We're already hard at work fixing mistakes from previous standards, this time with _Generic in C2y!

ThePhD | Improving _Generic in C2y | The Pasture | https://thephd.dev/improving-_generic-in-c2y


You must log in to comment.

in reply to @ThePhD's post:

this is nice! i was just thinking about this in terms of an "exactly this type" assertion

sometimes though i've wished _Generic could go in the other direction and admit more conversions, like to be able to have one rule that matches all data pointers or all integer types, particularly for printing sorts of macros like

_Generic((x),
  // handle all types that can convert to `void*`
  const void *: "%p",
  // all types that promote to `int`
  int: "%d",
  ...)

out of curiosity, are there folks that have looked into introducing more "generic" _Generic selectors like that into C?

There is a lot of work that's going into figuring out what more can be done with _Generic. Some people want certain branches to not be evaluated. Others want VLAs to have syntax so they can be matched on. And then, of course, there's the things you want to try to do with better conversions.

I would say if you want to accelerate seeing something you like, you should give a shot at prototyping it in Clang and throwing some code at it to see how it feels. I personally think different variations of _Generic that use a different keyword, e.g. _GenericPromoted (which would do the conversions you speak of known as "default argument promotions").