Not TRYING to start a flame war honest.

But... has C or C++ got PASCAL calling conventions?... if so is and/or/xor and not 4 part of them?..

eg...

int b;

void setup()
{
  b=10;
  //c code
  b = b ^ b;
  //C Form
  b = (b xor b);
  // xor (used in pascal);
  
  b = !b;
  //pascal
  b = not b;
  
  b = b | b;
  //pascal
  b = b or b;
  
  
  b = b & b;
  //pascal
  b = b and b;
}


void loop()
{
  
  
}

i don't have a vanilla c compiler to test this, but i find it odd, this compiles perfectly.

helps HEAPS to remember what's what for me now, and what to use. not trying to start a way, but are these operators intended? some kind of pascal/fortran influence going on there?

But... has C or C++ got PASCAL calling conventions?... if so is and/or/xor and not 4 part of them?

No, but there are often additions to the basic C/C++ compiler to enable that sort of stuff (for the weak minded that can't remember the simple C way...)

PaulS:

But... has C or C++ got PASCAL calling conventions?... if so is and/or/xor and not 4 part of them?

No, but there are often additions to the basic C/C++ compiler to enable that sort of stuff (for the weak minded that can't remember the simple C way...)

Using the C/C++ preprocessor you can accomplish a great deal in the way of making C/C++ look like another language; however this is ALWAYS a bad idea. The resulting code is hard to manage. No other programmers will have a simple time working on it. And many other well documented issues. Ultimately if you want to use PASCAL, then use pascal. You could use the GNU Pascal to C compiler chain, in conjunction with the standard AVR C/C++ chain. You might need to modify/create the nescessary support libraries. There are also commercial PASCAL compilers for the AVR.

In short use the correct tool for the task, don't try to use a hammer as a wrench...

Look for a file called iso646.h.

It is hard to use a hammer as a wrench, but quite good fun to use a wrench as a hammer.

 boolean you = false;
  you = not you;
  if (you == true) 
    return;

scary :D

I have used this before:

#define OR ||
#define AND &&
#define XOR !=
#define NOT !

boolean a,b,c;

void setup(){
//Just demonstrations, I doubt this does anythign useful.
  a = (b XOR c);
  b = NOT b;
  c = (b AND a);
  b = (a OR b);
}

Edit: or you can do this one for bitwise operators:

#define or |
#define and &
#define xor ^
#define not ~

byte a,b,c;

void setup(){
//Just demonstrations, I doubt this does anythign useful.
  a = 10;
  b = 103;
  c = 78
  a = (b xor c);
  b = not b;
  c = (b and a);
  b = (a or b);
}

Given the Arduino uses C++ instead of just C, you don’t need the defines, since and/and_eq/or/or_eq/not/not_eq are C++ keywords that map into the C counterparts.

#define OR ||
#define AND &&
#define XOR !=
#define NOT !

I once knew another Pascal programmer who started writing code in C. He didn't stop as above, but #defined every lit bit of C that he could into Pascal syntax. begin to {, end to }, = to :=, on and on to the end of time and sanity. I think for good measure, he also tossed in a little retranslated Basic syntax.

oric_dan(333): I once knew another Pascal programmer who started writing code in C. He didn't stop as above, but #defined every lit bit of C that he could into Pascal syntax. begin to {, end to }, = to :=, on and on to the end of time and sanity. I think for good measure, he also tossed in a little retranslated Basic syntax.

And this is one of the reasons I implemented the -save-temps (and more recently -save-temps=obj) option in GCC many, many years ago, so that I could see what was really being fed to the compiler when bug reports came up. The -save-temps option leaves a copy of the output after preprocessing and the assembler input file around.

int b;

void setup()
{
  b=10;
  //c code
  b = b ^ b;
  //C Form
  b = (b xor b);
  // xor (used in pascal);
  
  b = !b;
  //pascal
  b = not b;
  
  b = b | b;
  //pascal
  b = b or b;
  
  
  b = b & b;
  //pascal
  b = b and b;
}


void loop()
{
  
  
}

Just because it compiles doesn't always mean it's going to do what you think. Try throwing a few print statements in there, maybe we can fun over the results.

oric_dan(333): I once knew another Pascal programmer who started writing code in C. He didn't stop as above, but #defined every lit bit of C that he could into Pascal syntax. begin to {, end to }, = to :=, on and on to the end of time and sanity. I think for good measure, he also tossed in a little retranslated Basic syntax.

I seem to remember seeing a Jive macro set years ago that converted contemporary American slang into valid 'C'. :)

I seem to remember seeing a Jive macro set years ago that converted contemporary American slang into valid 'C'.

Haha, like the Simpsons example.

A whole nother = allocate some memory.

Come 'ere a minute = read value after short delay.

GoForSmoke: ``` int b;

void setup() {   b=10;   //c code   b = b ^ b;   //C Form   b = (b xor b);   // xor (used in pascal);     b = !b;   //pascal   b = not b;     b = b | b;   //pascal   b = b or b;       b = b & b;   //pascal   b = b and b; }

void loop() {     }




Just because it compiles doesn't always mean it's going to do what you think.
Try throwing a few print statements in there, maybe we can fun over the results.
int b;



void setup()
{
  Serial.begin(9600);
  b=1;
  //c code
  b = b ^ b;
  Serial.print("C Version: ");
  Serial.println(b);
  Serial.println();
  //C Form (interesting, does ^ not mean XOR? these conflict, the
  //rest (below match)
  b = (b xor b);
  Serial.print("Pascal Style Version: ");
  Serial.println(b);
  Serial.println();

  // xor (used in pascal);
  
  b = !b;
  Serial.print("C Version: ");
  Serial.println(b);
  Serial.println();

  //pascal
  b = not b;
  Serial.print("Pascal Style Version: ");
  Serial.println(b);
  Serial.println();

  b = b | b;
  Serial.print("C Version: ");
  Serial.println(b);
  Serial.println();

  //pascal
  b = b or b;
  Serial.print("Pascal Style Version: ");
  Serial.println(b);
  Serial.println();
  
  
  b = b & b;
  Serial.print("C Version: ");
  Serial.println(b);
  Serial.println();

  //pascal
  b = b and b;
  Serial.print("Pascal Style Version: ");
  Serial.println(b);
  Serial.println();
}


void loop()
{
  
  
}

I Think ^ is not the same as XOR but the rest seems to yeild identical values, but then my maths sucks badly, i use my fingers to count on still lol...

anyway, could someone throw it some real values to check to see what the differences actually are?

I may've missed it but nobody seems to have mentioned that the following keywords are simply part of the C++ standard.

and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq

I may've missed it

You have. Reply #6.

I have made more than enough pascal code in the last 20 something years (keeping in mind I am 33 years old) so when I hear

remember the simple C way

I automaticly dive into a hissyfit of piss poor documentation that only after I actually do it, does it seem "simple" ... in a C way heh

Disclaimer: I am Ctarded

I think I still have the 1985 issue of BYTE where Niklaus Wirth introduced Modula-2. He prefaced with the adage that if you want to write a computer program right, you write it twice and throw the first one away. Pascal was his first. But by 1985 Pascal was so entrenched it just wouldn't die.

It's so restrictive. Kind of like, retch, COBOL.

Ah, Pascal, My first real programming language.......... :)

BASIC doesn't cut it as a 'real' language.

cjdelphi:
I Think ^ is not the same as XOR but the rest seems to yeild identical values, but then my maths sucks badly, i use my fingers to count on still lol…

anyway, could someone throw it some real values to check to see what the differences actually are?

In the interests of brevity, I’m not going to quote your code, but it is seriously flawed, since you are using only one variable. In particular:

a = b & b;
a = b | b;

will always equal b, while:

a = b ^ b;

will always equal 0. In fact, xor reg,reg,reg is sometimes used to clear a register.

Now, if you want to see what the logical ops do, you need to do something like:

void setup (void)
{
    int i, j;

    Serial.begin (9600);

    for (i = 0; i < 2; i++) {
        for (j = 0; j < 2; j++) {
            Serial.print (i);
            Serial.print ("&");
            Serial.print (j);
            Serial.print (" = ");
            Serial.print (i & j);
            Serial.print (", ");
            Serial.print (i);
            Serial.print ("|");
            Serial.print (j);
            Serial.print (" = ");
            Serial.print (i | j);
            Serial.print (", ");
            Serial.print (i);
            Serial.print ("^");
            Serial.print (j);
            Serial.print (" = ");
            Serial.println (i ^ j);
       }
    }
}

void loop (void)
{
}

And it will print out:

0&0 = 0, 0|0 = 0, 0^0 = 0
0&1 = 0, 0|1 = 1, 0^1 = 1
1&0 = 0, 1|0 = 1, 1^0 = 1
1&1 = 1, 1|1 = 1, 1^1 = 0

pluggy: Ah, Pascal, My first real programming language.......... :)

BASIC doesn't cut it as a 'real' language.

Why?