"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Coding without braces: An alternate C Syntax

Coding without braces: An alternate C Syntax

Published on 2024-11-03
Browse:693

Coding without braces: An alternate C Syntax

I recently stumbled upon an interesting piece of C language trivia that underscores how different computers were when C was first created. Specifically, C allows the use of digraphs (two letter combinations that represent a single letter) like as alternatives of { and } and <: and :> as substitutes for [ and ]. The purpose of this was to provide an alternate syntax to support keyboards and character sets where braces and brackets were not available. The Gnu C Language manual mentions these digraphs as well as %: as an alternative to #. Since nothing on the internet can be trusted anymore I wrote a simple program and compiled it to verify the claims.

#include 

int main()  = ; 
    for (int i = 0; i ); 
    %>
    return 0;
%>

And lo and behold (don't take my word for it) it worked! While it's hard to imagine a keyboard without these symbols today, and I might be showing my ignorance of international keyboards here, I'm glad someone thought to include these alternatives.

But if the cpp reference is anything to go by there is is an expecation that all keyboards must have ?,

Call To Action ?

Hi ? my name is Diego Crespo and I like to talk about technology, niche programming languages, and AI. I have a Twitter a Mastodon, and Threads if you’d like to follow me on other social media platforms. If you liked the article, consider checking out my Substack. And if you haven’t why not check out another article of mine listed below! Thank you for reading and giving me a little of your valuable time. A.M.D.G

Release Statement This article is reproduced at: https://dev.to/deusinmachina/coding-without-braces-an-alternate-c-syntax-4oj0 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3