Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Re: Re: Teaching bottomline, part 3: what should improve.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Vincent Aravantinos <vincent.aravantinos@y...>
Subject: Re: [Caml-list] Re: Re: Teaching bottomline, part 3: what should improve.
> Date: Wed, 23 May 2007 15:21:55 +0200
> From: "Loup Vaillant" <loup.vaillant@gmail.com>
> Subject: Re: [Caml-list] Re: Re: Teaching bottomline,	part 3: what
> 	should improve.
>
> 2007/5/23, Vincent Aravantinos <vincent.aravantinos@yahoo.fr>:
>> On Wed, 23 May 2007, Loup Vaillant wrote :
>>
>>> (...)
>>
>>>> * Anonymous functions are still beyond most of them.
>>>
>>> That sounds surprising, for anonymous function are no different
>>> from named ones:
>>>
>>> 5;; (* a value *)
>>> fun x -> x+1;; (* another value, which happens to be a function *)
>>
>> Those are typically the comments of a "used-to-functional-
>> programming" guy.
>> It certainly doesn't match what a beginner would think (no beginner
>> will call a
>> function a "value").
>
> You are quite right. My point was to find a way to tell the beginners.
> A way to stress upon the fact that functions are values like any other
> (in Ocaml, at the very least).
>
> I see some difficulties, thought :
>
> First, the syntax:
> b = fun x -> x+1;; (* b defined as a functionnal value *)
> b x = x+1;; (* b defined as a mere function *)
>
> Second, imperative languages, where b can only be defined as a mere
> function. Many courses begin with an imperative language.
>
> Third, high school, where the only functions we dare name as such are
> of type number -> number. Derivation and composition, for instance,
> are named "operations", not functions. As if they have anything
> special (usefulness excepted). Finally, each function has a name in
> high shool mathematics.
>
>
>> Or do you really think that seeing functions as first-class object is
>> the natural way ?
>> IMHO this is not the case, and therefore not the case of a beginner.
>
> I agree. I just hope it can become A natural way.
>
>> To my eyes, there are (I mean, "in human mind" or at least in an
>> ocaml beginner's mind)
>> values AND functions. A function turns into a value (in the mind of
>> the programmer)
>> only when it is used by a higher order function.
>
> I think there are some other uses, too : data structures can contain
> closures for instance. A lazily evaluated value is a function (a
> closure).
>
>
>>> Did your students used map and fold-like functions much? These  
>>> almost
>>> require anonymous functions.
>>
>> Indeed, using map and fold puts the focus on the fact that functions
>> _can_ be values.
>> Thus their importance in a pedagogical context.
>
> Not only : most loops in a list or an array can be expressed as a
> combination of map and fold (and filter, and...). Using these
> significantly reduce the amount of code.
>
>> Maybe all this is just a matter of belief...
>
> I am quite a zeelot of abstraction. :)
>
> Regards,
> Loup

All agreed !

Regards,
Vincent