Named Parameters vs. Positional Parameters
Moderators: phlip, Moderators General, Prelates
-
- Posts: 79
- Joined: Thu Jun 21, 2012 5:09 pm UTC
- Contact:
Named Parameters vs. Positional Parameters
Take a side and stick with it to the bitter end.
Re: Named Parameters vs. Positional Parameters
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.)
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?
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?
Re: Named Parameters vs. Positional Parameters
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.
- Xanthir
- My HERO!!!
- Posts: 5367
- Joined: Tue Feb 20, 2007 12:49 am UTC
- Location: The Googleplex
- Contact:
Re: Named Parameters vs. Positional Parameters
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.
I agree - Python is awesome in this respect.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))
- Quizatzhaderac
- Posts: 1657
- Joined: Sun Oct 19, 2008 5:28 pm UTC
- Location: Space Florida
Re: Named Parameters vs. Positional Parameters
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. In 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.
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. In 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.
Last edited by Quizatzhaderac on Tue Aug 19, 2014 8:20 pm UTC, edited 1 time in total.
The thing about recursion problems is that they tend to contain other recursion problems.
Re: Named Parameters vs. Positional Parameters
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. 

"There are only two hard problems in computer science: cache coherence, naming things, and off-by-one errors." (Phil Karlton and Leon Bambrick)
coding and xkcd combined
(Julian/Julian's)
coding and xkcd combined
(Julian/Julian's)
Who is online
Users browsing this forum: No registered users and 3 guests