List Info

Thread: "ocaml_beginners"::[] Pattern matching of type constructors with arguments




"ocaml_beginners"::[] Pattern matching of type constructors with arguments
user name
2006-09-16 06:45:41
On Sep 15, 2006, at 10:56 PM, doug_arro wrote:

> Then I write the following statement in C:
>
> bar(foo(3));
>
> I know foo(3) is evaluated before the bar is called. 
So, what would
> be the reasons for C and OCaml to choose different
evaluation
> orders?  I am guessing it has to do with language
design.  Any
> insight here will be highly appreciated.

Well, first of all, writing bor(foo(3)) [or just bar (foo
3)] in  
ocaml also evaluates foo 3 then passes the result to bar. 
As for the  
evaluation order, I would think that a lot of that is
historical in  
nature.  Functional programming has long had function
application be  
of high precedence and left associative (perhaps even back
to the  
writings of Church -- I don't really know), and in every
paper I can  
remember reading has introduced a special operator for
function  
composition, so that foo bar 3 means (foo bar) 3, and foo .
bar 3  
means foo(bar 3).

There may, of course, be other reasons.  For example, this
thread [1]  
discusses why the evaluation order of the arguments to ocaml
 
functions is undefined.

[1] http://caml.inria.fr/pub/ml-archives/caml-list/2005/08/ 
e63da0e90ee230186d5aa78c6c4d18ab.en.html

William D. Neumann

"I eat T-bone steaks, I lift barbell plates, I'm
sweeter than a
German chocolate cake. I'm the reflection of perfection,
the number
one selection. I'm the man of the hour, the man with the
power, too
sweet to be sour. The ladies' pet, the men's regret, where
what you
see is what you get, and what you don't see, is better
yet."

          --Superstar Billy Graham





Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    ht
tp://groups.yahoo.com/group/ocaml_beginners/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:ocaml_beginners-digest@yahoogroups.com 
    mailto:ocaml_beginners-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



[1]

about | contact  Other archives ( Real Estate discussion Medical topics )