Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

syntax is heck

1 view
Skip to first unread message

Raoul Duke

unread,
Mar 15, 2025, 10:28:25 PMMar 15
to pi...@googlegroups.com
has anybody come up with the ultimate best (least bad?) syntax for
when there are optional arguments, and default values? taking into
consideration potential overloading? like, what would be the safest
most clear most unambiguous most internally consistent design?

positional arguments with no names at the call site are clearly
unacceptably bad it seems to me.

named arguments are better. (i like them even w/out it being about optionality.)

named arguments: should ordering be involved in any way?

e.g. python kwargs has gone through all sorts of revisions and every
step of the way has had terrible dx problems it seems to me.

Mike Austin

unread,
Mar 17, 2025, 5:25:22 PMMar 17
to PiLuD
C# has named and optional arguments and is feels sane.

anExample.ExampleMethod(3, optionalint: 4);

You can name all the parameters in calls if you like, but it can become overwhelming like Objective-C.

In JavaScript you'll see the .exampleMethod(3, { optionalint: 4 }) pattern used often, where the last object is optional named values.

The worst case without named arguments is foo(3, true). But then IDSs these days can insert the parameter name without actually having in the source.
Reply all
Reply to author
Forward
0 new messages