Hi Jeff,

I test your code and I'm getting exactly the same error as you. It seems at the moment operations can't start with !, I tried several other operators, the following worked correctly:

1
let (-!!) a b = a - b;;
1
let (-!) a b = a - b;;

But this operator fails with the same error:

1
let (!-) a b = a - b;;

I suppect this is a bug in the compiler rather than a bug in my book, since the rules seem to be in line with the informal specification [1] and ! is sometime used as a special operator. I'll send a bug report to the F# team (although they'll probably read it here soon anyway).

Cheers,
Rob

[1] [link:research.microsoft.com]

By on 7/23/2007 11:17 AM ()

Hi,

This is not a bug. Operators type and priority are defined by their first character (the first character, ignoring leading . and $). An operator starting by !, ? or ~ is an infix operator. Remember: you write !foo (when foo is a ref).

From lexyacc.aspx, priorities are:

1
2
3
4
5
6
7
8
9
-OP +OP -. %left

*OP /OP %OP %left

**OP %right

?? %left

!OP ?OP ~OP %prefix

Edit: ok, Don was faster. :)
I believe that if each operator could be used either as infix or as prefix, that wouldn't lead to conflicts in the grammar (like with infix + and prefix +). And I think that would not lead to incompatibilities with old code.

Laurent.

By on 7/23/2007 1:15 PM ()

Thanks Rob! Good to know. It's worth mentioning that I can't get operators to start with '?' either.

--
Jeff S.

By on 7/23/2007 11:27 AM ()

Operators beginning with "!", "?" and "~" are always prefix - this is a design decision taken by OCaml and one that we have stuck with for F#.

See [link:research.microsoft.com].

I'll made a note to make this clearer in the spec as we revise it (soemthing we're currently doing).

cheers

Don

By on 7/23/2007 1:02 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper