Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualL. Spiro

Posted 05 September 2012 - 06:38 AM

“and” and “or” are very rare and I have never seem them in practice, but at least they are documented.
Here is a snippet of code that may look entirely alien to most of you.

int iBlah<:100:>;
if ( bBleegers and bBloopers )
	for ( int i = sizeof( iBlah ) / sizeof( iBlah<:0:> ); i--; ) <% iBlah<:i:> = i; %>

I wrote this on paper for my coworkers today and asked, “What language is this?”.
All of them are very experienced and none of them were able to answer correctly.

It’s plain C/C++.  Actually “and” is not a C keyword, but the rest of it will compile in any C compiler (assuming you have declared bBleegers and bBloopers).
Try it for yourself.

C/C++:
<% = {
%> = }
<: = [
:> = ]

C++ Only:
and = &&
or = ||


These tokens were created because 20 years ago not all keyboards had &, |, {, }, [, and ] characters.  So these are all exact drop-in replacements.


Again, I have never seen any of these in actual use and there seems not to be any documentation of it anywhere.
The only reason I know about them is because I wrote a C compiler a long time ago.
The lexer grammar for ANSI C can be found here:
http://www.lysator.l...-grammar-l.html


All that being said, I have to honestly question how the original poster knew about “and” and especially why he or she is actually using it.
It does not appear in tutorials or books.  How could a beginner possibly not know about and use &&?  Any learning resource you ever find will be using only &&, so I have to ask, where on earth did you learn C++?  Even if you come from a scripting background you would have had to look at some tutorial or learning source on C++ somewhere, and there is no chance it would have been using &&…


L. Spiro

#2L. Spiro

Posted 05 September 2012 - 06:35 AM

“and” and “or” are very rare and I have never seem them in practice, but at least they are documented.
Here is a snippet of code that may look entirely alien to most of you.

int iBlah<:100:>;
if ( bBleegers and bBloopers )
	for ( int i = sizeof( iBlah ) / sizeof( iBlah<:0:> ); i--; ) <% iBlah<:i:> = i; %>

I wrote this on paper for my coworkers today and asked, “What language is this?”.
All of them are very experienced and none of them were able to answer correctly.

It’s plain C/C++.  Actually “and” is not a C keyword, but the rest of it will compile in any C compiler (assuming you have declared bBleegers and bBloopers).
Try it for yourself.

C/C++:
<% = {
%> = }
<: = [
:> = ]

C++ Only:
and = &&
or = ||


These tokens were created because 20 years ago not all keyboards had &, |, {, }, [, and ] characters.  So these are all exact drop-in replacements.


Again, I have never seen any of these in actual use and there seems not to be any documentation of it anywhere.
The only reason I know about them is because I wrote a C compiler a long time ago.
The lexer for ANSI C can be found here:
http://www.lysator.l...-grammar-l.html


All that being said, I have to honestly question how the original poster knew about “and” and especially why he or she is actually using it.
It does not appear in tutorials or books.  How could a beginner possibly not know about and use &&?  Any learning resource you ever find will be using only &&, so I have to ask, where on earth did you learn C++?  Even if you come from a scripting background you would have had to look at some tutorial or learning source on C++ somewhere, and there is no chance it would have been using &&…


L. Spiro

#1L. Spiro

Posted 05 September 2012 - 06:34 AM

“and” and “or” are very rare and I have never seem them in practice, but at least the are documented.
Here is a snippet of code that may look entirely alien to most of you.

int iBlah<:100:>;
if ( bBleegers and bBloopers )
    for ( int i = sizeof( iBlah ) / sizeof( iBlah<:0:> ); i--; ) <% iBlah<:i:> = i; %>

I wrote this on paper for my coworkers today and asked, “What language is this?”.
All of them are very experienced and none of them were able to answer correctly.

It’s plain C/C++.  Actually “and” is not a C keyword, but the rest of it will compile in any C compiler (assuming you have declared bBleegers and bBloopers).
Try it for yourself.

C/C++:
<% = {
%> = }
<: = [
:> = ]

C++ Only:
and = &&
or = ||


These tokens were created because 20 years ago not all keyboards had &, |, {, }, [, and ] characters.  So these are all exact drop-in replacements.


Again, I have never seen any of these in actual use and there seems not to be any documentation of it anywhere.
The only reason I know about them is because I wrote a C compiler a long time ago.
The lexer for ANSI C can be found here:
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html


All that being said, I have to honestly question how the original poster knew about “and” and especially why he or she is actually using it.
It does not appear in tutorials or books.  How could a beginner possibly not know about and use &&?  Any learning resource you ever find will be using only &&, so I have to ask, where on earth did you learn C++?  Even if you come from a scripting background you would have had to look at some tutorial or learning source on C++ somewhere, and there is no chance it would have been using &&…


L. Spiro

PARTNERS