Language Constructs Help Needed

Mar 22, 2009 at 9:54 PM
Hi,

Can someone please explain  me a couple of things that I have found looking over the Singularity code?

Here goes:

1. expose(bar)
{
return bar;//use bar in some way
}

2. void foo(barType @bar)
{
barType ana=@bar;
}

Thank you,
Alex.
Coordinator
Mar 31, 2009 at 4:10 AM
Hi Alex. Good questions - "expose" is a Spec# feature (Sing# is an extended version of Spec#) that you can read about here:

http://research.microsoft.com/en-us/projects/specsharp/krml136.pdf

The "@" construct is new to me and I can't find a reference for it. Can you point to an example? Thanks, and I hope this helps.
--
Derrick Coetzee
Microsoft Research Operating Systems Group developer

Apr 1, 2009 at 10:53 AM
Hi,

Thank you for the info. I'll take a look.

The "@" construct is used in Pong or Keyboard drv. I don't remember exactly.

All the best,
Alex.
Apr 4, 2009 at 6:00 PM
Ok, It was in pong app.

private static void SetStateFromChar(char c, bool @state)
        {
            switch (c) {
                case (char)Keyboard.Keys.UP_ARROW:
                    inputUp[1] = @state;
                    break;
                case (char)Keyboard.Keys.DOWN_ARROW:
                    inputDown[1] = @state;
                    break;
                case 'a':
                    inputUp[0] = @state;
                    break;
                case 'z':
                    inputDown[0] = @state;
                    break;
            }
        }
All the best,
Alex.

Apr 15, 2009 at 4:42 PM
Edited Apr 15, 2009 at 4:45 PM
In C# you can use @ to prefix an identifier which is a reserved word (Intellisense can ignore the prefix, which is why it's not the same as just using an underscore or something). I don't know Spec# or Sing#, but I suspect that "state" is a reserved word.
Apr 25, 2009 at 12:09 PM
Thank you,
Alex