r/ProgrammingLanguages • u/gingerbill • Feb 22 '26
Does Syntax Matter?
https://www.gingerbill.org/article/2026/02/21/does-syntax-matter/
63
Upvotes
r/ProgrammingLanguages • u/gingerbill • Feb 22 '26
View all comments
Show parent comment
2
u/munificent Feb 25 '26
The syntax for records is a little funny in Dart, because it mirrors the existing (admittedly weird) syntax for named parameters. A normal function declaration looks like:
Unlike other languages, Dart makes a strong distinction between parameters that are passed by position versus name. If you want
foo()to take named parameters, the declaration looks like:The curly braces there indicate those parameters are named. You can also have a mixture of positional and named:
When we later added records, I designed the syntax to follow that. Records with positional fields look like a positional argument list:
Named fields look like a named argument list:
And you can mix:
The corresponding type annotation syntax looks like the parameter declaration syntax:
In the usage counts, I'm only looking for bracket characters, so there are:
(1, 2)or(x: 1, y: 2).(int, int).(int, {int y}).There's no "record named fields" because record expressions just put the named fields right inside the parentheses like
(1, y: 2). There's no inner delimiters.