Comment

Comment by patrec

Let's take your static printf as a concrete example. Here's what a not so great error message looks like (ocaml's built in Printf):

  utop # Printf.sprintf "Some int: %d another int: %d" 1 "2";;
  Error: This expression has type string but an expression was expected of type int
Here's what a good error message looks like:

  clang -Wall printf.c
  printf.c:6:52: warning: format specifies type 'int' but the argument has type 'char *' [-Wformat]
     printf ("Some int: %d some other int: %d\n", 1, "2");
                                           ~~        ^~~
                                           %s
Notice how it also highlights the mismatched part in the string-based DSL.
parent patrec 10 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton