Sujet : When Is A High/Low-Level Language Not A High/Low-Level Language?
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.cDate : 16. Aug 2024, 06:58:10
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v9mppi$1b5hk$1@dont-email.me>
User-Agent : Pan/0.159 (Vovchansk; )
Here’s a little bit of Python code, from <
https://gitlab.com/ldo/inotipy>:
info_type = infoptr.contents.info_type
infoptr = ct.cast \
(
infoptr,
ct.POINTER
(
{
FANOTIFY.EVENT_INFO_TYPE_FID : FANOTIFY.event_info_fid,
FANOTIFY.EVENT_INFO_TYPE_DFID_NAME : FANOTIFY.event_info_fid,
FANOTIFY.EVENT_INFO_TYPE_DFID : FANOTIFY.event_info_fid,
FANOTIFY.EVENT_INFO_TYPE_PIDFD : FANOTIFY.event_info_pidfd,
FANOTIFY.EVENT_INFO_TYPE_ERROR : FANOTIFY.event_info_error,
}[info_type]
)
)
That’s a conditional cast, based on a common header field, to the
appropriate struct type for that data block.
That’s not just a switch-expression, it’s a switch-expression
returning a type.