Re: [hackers] [st] [patch] use goto in xloadfonts

From: Markus Teich <>
Date: Mon, 22 Jun 2015 15:45:30 +0200

FRIGN wrote:
> "Roberto E. Vargas Caballero" <> wrote:
> > I personally don't think is harder. I think is a common pattern in
> > C to have die calls in the end of the function and gotos to them.
> > The main problem that I can see here is the label, whose name is
> > not significative enough: err, which error?, and if we have to add
> > more errors in the future, do we have to change this label and all
> > the gotos to this label?. I think a label like 'cant_open_font' is
> > better. I usually like short names, but in the case of goto the
> > story is totally different, because you have a modification in the
> > control flow and it should be clear why it is done.
> Could you give me some information if a cleanup is necessary when the
> font fails to load? Is there some possibility open with the gotos now to
> have some kind of cleanup?
> In general, I prefer this kind of error-handling way over exceptions. :)


although this is already decided I have some further points to consider in
further decisions:

I also use this scheme regularly, but I don't think it is useful here since:

- there is no cleanup done in any case
- we don't have to set different return values
- It's just a plain call to die() here. The complexity with the goto comes from
  the fact, that the reader has to „jump“ to the function end instead of just
  seeing the die() call directly.

Of course if the rest of st would use the goto scheme, consistency would be a
good argument (more than enough to overweigh the previous ones) to use it here
too even if it's not needed.

The behaviour that st dies instantly if a font could not be loaded is not so
good, so we could output a warning and/or use a fallback font or use libsl in st
(I think that has already been discussed).

Received on Mon Jun 22 2015 - 15:45:30 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 22 2015 - 15:48:10 CEST