Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Black for C++: what if your indentation was your syntax tree?

I recently wrote a line of C++ that took me three passes to read. It was not clever code. It was an ordinary constructor initializer list. Display :: Display ( Keyboard & keyboard , int output , const Vector & position , const Vector & size , const Vector & expandTo , Screen screen ) : keyboard_ ( keyboard ) , output_ { output } , screen_ { screen } , cursor_ ( enter ( position ) ) ,…

The author of the provided C++ code experienced difficulty understanding the syntax tree of an indentation-heavy constructor initializer list. Most C++ formatting aligns lines based on a column budget, which does not provide clarity on the structure of the code. The nested conditional in the code example made it particularly challenging to discern the relationships between different elements.

Structured indentation offers a solution to this problem. This approach follows four simple rules that align with the syntax of the code. Contexts that do not fit on a line begin with their opening token at the end of the line, followed by indented contents. Contexts with an opening token but no closing token, such as the ternary operator, are indented after the token and dedented when the context ends. Items within an indented block are written one per line, making the structure more apparent.

When applying structured indentation to the example code, the resulting output demonstrates a more readable and organized format. The visual line, as defined by the structured indentation spec, ensures that the contents of a context form a contiguous block, with closing tokens returning to the column of their opener. This maintains the code's shape at any depth, allowing for easy comprehension of the relationships between different elements.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

A Korean indie app market reached 878 services in 5 days. The numbers are about distribution, not building.

Shipping stopped being the hard part. With AI coding tools, a solo builder can put a working web app online in a week that would have taken a small team a quarter two years ago.

  • BlackMango indie app marketplace launched on November 24, 2026
  • Platform lists 878 services in 5 days, including web services, apps, games, PC programs, AI tools
  • Creators submit listings in 1 minute, gain permanent pages with maker stories and coupons

Our infrastructure was code. We still deployed by hand

Is GitOps more than just IaC? I was assigned to review a PR on the infrastructure repository, a small change adjusting some replica counts and adding a bit of capacity to our production cluster…

  • Infrastructure initially deployed manually, not via automation
  • PR reviewer approved change, but it remained unapplied
  • Process required human reconciler and manual scaling

Keep repeated checkbox values when building a query string

AI disclosure: This article and its example were generated by an AI assistant. A filter form often needs to send more than one value under the same key.

  • Keep repeated checkbox values in query string
  • URLSearchParams prevents data loss
  • Avoid plain object conversion for filters

Defending GeoServer against XML injection beyond the patch

Defending GeoServer against XML injection beyond the patch The direct fix for CVE-2026-120705 is a GeoServer or GeoTools update that restores entity resolver protection in the vulnerable WFS parsing…

  • XML injection flaw in GeoServer's WFS GetFeatureById operation
  • Mitigation includes disabling WFS for anonymous users and restricting access
  • Updated GeoServer versions: 2.27.7, 2.28.6, 3.0.2

More from Saturday, 28 November 2026 →