🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Garry Wiegand Fri, 15 Feb 1991 20:41
Re: named parameters
#828
Author: Garry Wiegand
Date: Fri, 15 Feb 1991 20:41
49 lines
2108 bytes
In article <5120@vela.acs.oakland.edu> schemers@vela.acs.oakland.edu (Roland Schemers III) writes:
>I was wondering if the concept of named parameters has ever came up.
>Right now you can declare a function like so:
>
>some_func(int a, int b=0);
>
>But since you can only have default values listed at the end this makes for
>a real pain. Has anyone proposed the following:
>
>some_func(int a=10, int b=0);
>...
>Comments?

Roland -

It would be lovely. When I read through the ARM I red-flagged the

    some_func(int a, int b=0)

syntax as a stylistic Bad Idea - it's OK for one (or maybe two)
optional arguments, but for multiple optional arguments it
degenerates into something that is very hard to explain to a "normal
human". 

Ie, if you have a function with parameters (a,b,c,d)

it's purely good luck if the argument "d" that would logically be
mentioned last also happens to be the argument that would naturally
be omitted first, 

it's unusual that every single time you might want to omit "c" you
will already have decided to omit "d", 

it's improbable that every single time you might want to omit "b" you
will already have decided to omit "c" and "d", and

it's approaching absurd (except in specially-constructed cases) that
every single time you might want to omit "a" you will already have
decided to omit "b", "c" and "d".

So it looks to me like the ARM's optional-argument style is
brain-dead, and just clutters up the language to no good purpose.

Real optional arguments, such as you propose, would be very
interesting, but you will probably run into the argument that the
":=" pseudo-operator "doesn't look like C". 

Garry Wiegand    ---    Ithaca Software, Alameda, California
...!uunet!ithaca!garry, garry%ithaca.uucp@uunet.uu.net
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads