Deutsch   English   Français   Italiano  
<v9mppi$1b5hk$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.lang.c
Subject: When Is A High/Low-Level Language Not A High/Low-Level Language?
Date: Fri, 16 Aug 2024 05:58:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <v9mppi$1b5hk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 16 Aug 2024 07:58:10 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="fe72d36c65c5a55eac1ba2ec475c4532";
	logging-data="1414708"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX185EaibTph2RlRHEsFbiYtR"
User-Agent: Pan/0.159 (Vovchansk; )
Cancel-Lock: sha1:ykM3n2oOZ0Ygi29tk2X+fPlsf5A=
Bytes: 1741

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.