Will.Whim

A weblog by Will Fitzgerald

F# no parameter functions

Notes to myself: F# version

*Whenever* writing or using a no parameter function, give it an empty parameter list.

  let long_running_function() =
    do_something_that_takes_a_long_time()

not:

 let long_running_function =
    do_something_that_takes_a_long_time

or

 let long_running_function =
    do_something_that_takes_a_long_time()

The last example will create a (global) non-function variable which evaluates to the result of the do_something function at load/compile time; probably not what is wanted.

Just wasted about 4 hours on this (since it was taking a long time, and consumed all the resources on my machine, it was difficulter to debug).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: