Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* optimizing trivial functions
@ 2006-11-21 23:20 Sean McLaughlin
  2006-11-26 13:36 ` [Caml-list] " Sean McLaughlin
  0 siblings, 1 reply; 3+ messages in thread
From: Sean McLaughlin @ 2006-11-21 23:20 UTC (permalink / raw)
  To: caml-list

Hello,

   Will the Ocaml compiler optimize the following code to let y = ()?
I'm designing a program that will depend heavily on whether this code
is optimized in this way.

let f x1 x2 ... x100 = ()
let y = f x1 ... x100

Thanks,

Sean


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] optimizing trivial functions
  2006-11-21 23:20 optimizing trivial functions Sean McLaughlin
@ 2006-11-26 13:36 ` Sean McLaughlin
  2006-11-27 12:00   ` Dmitry Bely
  0 siblings, 1 reply; 3+ messages in thread
From: Sean McLaughlin @ 2006-11-26 13:36 UTC (permalink / raw)
  To: Sean McLaughlin; +Cc: caml-list


To answer my own question, of course it can't do that, because the
arguments could have side effects.   I wonder if Haskell would do  
this...

Sean

f (print_int 5) ...



On Nov 21, 2006, at 6:20 PM, Sean McLaughlin wrote:

> Hello,
>
>   Will the Ocaml compiler optimize the following code to let y = ()?
> I'm designing a program that will depend heavily on whether this code
> is optimized in this way.
>
> let f x1 x2 ... x100 = ()
> let y = f x1 ... x100
>
> Thanks,
>
> Sean
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] optimizing trivial functions
  2006-11-26 13:36 ` [Caml-list] " Sean McLaughlin
@ 2006-11-27 12:00   ` Dmitry Bely
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Bely @ 2006-11-27 12:00 UTC (permalink / raw)
  To: caml-list

On 11/26/06, Sean McLaughlin <seanmcl@cmu.edu> wrote:

> >   Will the Ocaml compiler optimize the following code to let y = ()?
> > I'm designing a program that will depend heavily on whether this code
> > is optimized in this way.
> >
> > let f x1 x2 ... x100 = ()
> > let y = f x1 ... x100

Yes, ocamlopt can do that.

> To answer my own question, of course it can't do that, because the
> arguments could have side effects.
>
> f (print_int 5) ...

So what? The arguments will be evaluated but the function call will be
optimized away.

I guess you are trying to implement some debugging that can be
switched off in the release version? If so, the following might be
interesting for you:

http://caml.inria.fr/pub/ml-archives/caml-list/2003/09/f2bf1cc8545d5e073638bd70d02b5056.en.html

- Dmitry Bely


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-27 12:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-21 23:20 optimizing trivial functions Sean McLaughlin
2006-11-26 13:36 ` [Caml-list] " Sean McLaughlin
2006-11-27 12:00   ` Dmitry Bely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox