[Haskell-cafe] Parameters and patterns

Yves Parès limestrael at gmail.com
Sat Oct 1 16:38:17 CEST 2011

I think every people will have different terms.
For instance, for my teachers, argument and parameter were synonyms, and :

in the definition :
f x = x + 3
x was a _formal_ parameter (or argument)

and in
f 32
32 was the _effective_ parameter.

So, short answer: don't bother.
Context makes things clear enough.

2011/10/1 José Romildo Malaquias <j.romildo at gmail.com>

> Hello.
> When studing programming languages I have learned that parameter is a
> variable (name) that appears in a function definition and denotes the
> value to which the function is applied when the function is called.
> Argument is the value to which the function is applied.
> The parameter allows the manipulation of the argument in the body of the
> funtion definition in order to produce the result.
> Now I am not sure how to apply these concepts to Haskell, as Haskell
> uses pattern matching to deal with argument passing to functions.
> For instance, in the definition
>  f x = 2 * x + 1
> x is a parameter, and in the application
>  f 34
> 34 is an argument.
> But in the definition
>  g (_:xs) = xs
> what is the parameter of the function g? Is it the pattern (_:xs)? If so
> then a parameter is not necessarily a variable anymore, and that seems
> very strange. And what is xs? Is it a parameter, although it does not
> denote the value to which the function is aplied, but just part of it?
> I am writing some slides to use in my functional programming classes,
> but I am not sure how to deal with these terms.
> Any comments?
> Romildo
> --
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20111001/3eda863b/attachment.htm>

More information about the Haskell-Cafe mailing list