Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Strange behaviour of Do in Compile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82125] Strange behaviour of Do in Compile
  • From: "Andrew Moylan" <andrew.j.moylan at gmail.com>
  • Date: Sat, 13 Oct 2007 03:41:37 -0400 (EDT)

Compile[{}, Do[If[i > 10, Return[i + 1]], {i, 10}]][]

On my machine, this returns such values as:
176792864
176795048
176797232

The following slight modification always returns the value 11:

Compile[{}, Do[If[i > 10, Return[i]], {i, 10}]][]

Can anyone explain this behaviour?

Anyway, I guess the moral is: always explicitly return a value from Compile,
and don't rely on the usual return value properties of flow-control
constructs like Do.



  • Prev by Date: Re: Re: "dereference" variable
  • Next by Date: Re: Re: [Mathematica 6] Format->Magnification does not
  • Previous by thread: Re: JLink
  • Next by thread: Re: Strange behaviour of Do in Compile