Don't miss an insight. Subscribe to Techopedia for free.


Egyptian Brackets

What Does Egyptian Brackets Mean?

“Egyptian brackets” is an IT slang term for situations where
programmers include a curly bracket that contains a function at the end of a
code line after the function name, arguments, conditional statements or
anything else that precedes the actual function code. The second curly bracket
is located on its own line of code, underneath the last line of code contained
in the function. This results in the first bracket being situated above and to
the right of the second bracket, which in a general sense mimics the construction
of a conventional Egyptian hieroglyphic showing a dancer. For this reason, this
code layout convention is called “Egyptian brackets.”


Techopedia Explains Egyptian Brackets

Egyptian brackets are also called K&R C style, named for
programmers Brian Kernighan and Dennis Ritchie who supposedly pioneered this
style in the 1970s. The use of Egyptian brackets goes to the heart of how
coders determine how to structure function code. One might think that the more
common convention would be to include both curly brackets on one line, with the
code in the middle. However, it is far more common for programmers to include
each curly bracket on a separate line, so that both brackets sit at the far
left of the screen. Critics call this poor layout and point to the overuse of
code lines, but others contend that having the brackets on the left and on
their own lines makes code more readable and enhances its aesthetic.


Related Terms