sumtype.h

Languages and libraries

c header library

SHOW HN2024

92points
43comments
#893of 3,515 in 2024
Top 26%of 2024 by points

How HN took it

RoastedHalf or more of the comments are critical

0 positive, 2 neutral or asking, 1 mixed, 3 critical, out of 6 comments about the project. Thread score -0.31.

Docs: 0 for, 1 againstIdea: 0 for, 1 againstExecution: 0 for, 1 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Nice small standard-conforming C99 header, fast to compile

    From 2 comments
    • Nice system built with only a couple of C99 macros. That small header also achieves matching for specific C types over the "sum types". In the context of C99, isn't tagged union…
      feb on HN
    • Saw the title and thought "Didn't I just see C sum types in HN recently?" https://news.ycombinator.com/item?id=40307098 > Inspired by datatype99, but consisting of one small…
      ackfoobar on HN

Objections

  • Not very practical without type variables; misses generics of Haskell-style ADTs

    From 1 comment
    • It's interesting but not very practical. It's an "algebra of types" with only constants, no variables, since C does not have type variables. Thus it misses much of the point of…
      chongli on HN
  • Preprocessor macros cause messy compiler errors and warnings

    From 1 comment
    • It's a nice idea, but I don't think it adds enough clarity to the code to justify the messy compiler warnings and errors that this kind of preprocessor abuse will eventually cause.
      xurukefi on HN

Requests

  • Add type variables to C

    From 1 comment
    • I got to say adding type variables to C would be super duper. And to me actually feels rather C like as well.
      Gibbon1 on HN

Questions

  • Why link to GitHub rather than the SourceHut repository

    From 1 comment
    • I know it's a minor thing, but why does this link to GitHub? The repository is described only as being a mirror of a SourceHut repo, and the user's profile has a banner telling…
      danielspace23 on HN
  • Isn't tagged union the more usual name than sum type in C

    From 1 comment
    • Nice system built with only a couple of C99 macros. That small header also achieves matching for specific C types over the "sum types". In the context of C99, isn't tagged union…
      feb on HN

Alternatives named

  • datatype99 C99 macro header

    From 1 comment
    • Saw the title and thought "Didn't I just see C sum types in HN recently?" https://news.ycombinator.com/item?id=40307098 > Inspired by datatype99, but consisting of one small…
      ackfoobar on HN
  • std::variant in C++

    From 1 comment
    • +1. It cannot possibly be worse than the C++ `std::variant` blunder.
      tempodox on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/40478175)