Plain – Alternative Syntax

I have a friend that constantly complain that Plain syntax don’t look like C, so here it is – the C’ifed alternative version…

Use System;
Module Servo32
{
            Enum Byte ChannelMode
            {
                        DigitalIn,
                        DigitalOut,
                        AnalogueIn,
                        AnalogueOut,
                        PWMOut,
                        Servo,
            };

            Object Channel
            {
                        ChannelMode mode;       
                        uint32 frequency;
                        uint32 duty;
                        uint32 servoPosition;
                        real32 analogueValue;
                        bit digitalValue;
           };

            Interface C Channel chan[32];
            on Update(uint32 x)
            {
                        Transaction (chan[c])
                        {
                                   if(chan[c].digitalValue=1)
                                                           chan[c-4].servoPosition = 180;
                                   else
                                                           chan[c-4].servoPosition = 0;
                                   end
                        }Update;
            }

            int16 x;

            Transaction (chan[1..8])
            {
                        for x=1 to 4
                        {
                                    chan[x].mode = ChannelMode.Servo;
                                   chan[x].frequency=50;
                                    chan[x].servoPosition=0;
                        }
 
                        for x=5 to 8
                        {
                                    chan[x].mode = ChannelMode.DigitalIn;
                        }
            }Update;
}

This is just an alternative syntax for the fun of it – I lost a few details in the transfer + we could need a few more changes. But, the reason I am not using this syntax is because the other syntax form is closer to an Assembly Language – one line one instruction concept. I also believe that since we will use C/C++ to fuel Plain the languages should be very different. I have working in C++, Managed C++ and C# at the same time and it was confusing to keep the languages apart.

Leave a Reply

Your email address will not be published. Required fields are marked *