Named Parameters vs. Positional Parameters

Please compose all posts in Emacs.

Moderators: phlip, Moderators General, Prelates

Named parameters or positional parameters?

Named! functionCall(b=2, a=1);
2
8%
Positional! functionCall(1, 2);
5
19%
Both!
19
73%
Neither!
0
No votes
 
Total votes : 26

Named Parameters vs. Positional Parameters

Postby willaaaaaa » Thu Jun 21, 2012 5:44 pm UTC

Take a side and stick with it to the bitter end.
willaaaaaa
 
Posts: 79
Joined: Thu Jun 21, 2012 5:09 pm UTC

Re: Named Parameters vs. Positional Parameters

Postby tetsujin » Thu Jun 21, 2012 11:29 pm UTC

Named can make calling interfaces very versatile and the significance of the parameters very easy to discern, and positional can make them very compact (which can also lead to improved clarity under certain circumstances).

So, both. Python is awesome.

(One case where I dealt with named parameters in Python was dealing with the serial library. I couldn't tell you the right order for the calling arguments when creating a serial port object, but supplying named arguments makes it pretty easy to get up and running without a major hassle.)
---GEC
I want to create a truly new command-line shell for Unix.
Anybody want to place bets on whether I ever get any code written?
User avatar
tetsujin
 
Posts: 420
Joined: Thu Nov 15, 2007 8:34 pm UTC
Location: Massachusetts

Re: Named Parameters vs. Positional Parameters

Postby ycc1988 » Fri Jun 22, 2012 5:33 am UTC

Named parameters allow for simple use of default values. For example, a plotting function may have default font faces, line styles, etc. MATLAB/Octave doesn't have true named parameters, but gets around this with some clever (i.e. annoying to implement) parsing.
ycc1988
 
Posts: 28
Joined: Fri Jun 22, 2012 5:13 am UTC

Re: Named Parameters vs. Positional Parameters

Postby Xanthir » Mon Jun 25, 2012 11:33 pm UTC

Both. Positional parameters for the arguments that are absolutely necessary. Named optional params for *everything* else. And, for consistency, let the required parameters be nameable too.

I agree - Python is awesome in this respect.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))
User avatar
Xanthir
My HERO!!!
 
Posts: 4023
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex

Re: Named Parameters vs. Positional Parameters

Postby Quizatzhaderac » Tue Jul 17, 2012 6:44 pm UTC

If I had to pick one: positional.

That said I don't see good reasons not to have both. Though it does seem that positional has a relative advantage for strongly typed languages and named for weakly typed. Java a method that takes a bean, a string, an int, then a boolean is a lot clearer than a ruby method that takes an object, a second object, another object, then finally an object.
So if you don't believe you have a cat, that's actually evidence that you have an infinite cat.
Quizatzhaderac
 
Posts: 473
Joined: Sun Oct 19, 2008 5:28 pm UTC
Location: Space Florida

Re: Named Parameters vs. Positional Parameters

Postby Jplus » Mon Jul 23, 2012 1:13 pm UTC

I'm missing the otter/duck option. Named parameters can be useful but positional ones are fine too, so really I couldn't care less. :)
Hey, like coding? Perhaps you should check out the red spider project.
Feel free to call me Julian. J+ is just an abbreviation.
User avatar
Jplus
 
Posts: 1098
Joined: Wed Apr 21, 2010 12:29 pm UTC


Return to Religious Wars

Who is online

Users browsing this forum: No registered users and 4 guests