Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining my own preprocessor directives in F#

Tags:

.net

f#

fsi

I have an F# script that I intend to use both at home and at work. The script shall work similarly in both places, yet, I have a set of issues to deal with at work (mostly regarding firewalls and http proxies) so I'd like to run my script in a slightly different way in one case and in the other.

I imagine that ideally I'd set a special flag (directive) at the FSI level, so I could have #if AT_WORK to deal with some sharp corner cases.

How to accomplish this?

like image 393
devoured elysium Avatar asked Feb 05 '14 12:02

devoured elysium


1 Answers

Yes, you can define your own symbols to use with conditional compilation, when you call FSI do it like this:

Fsi.exe --define:AT_WORK yourScript.fsx

See http://msdn.microsoft.com/en-us/library/dd233172.aspx

like image 79
Gus Avatar answered Sep 22 '22 06:09

Gus