**Note: This may not be the correct forum for this post; I posted here as I thought it may be related in at least an indirect way. Please move if necessary.

I have never knowingly worked on any projects where I had to attempt to extend a language. I hear this concept thrown around, but I do not have any concrete concept of implementing this. I am not at this time in need of doing this but I believe it is inevitable at some point to be able to at least understand it better. I have done research via the 'Net but only find what I consider vague definitions and examples.

As an over-view at this point, I would define "extending" a language to be taking options available in one language (say for example "C") and using them to enhance another language such as Python, for example.

I have read that Python and Perl are considered "glue" languages used to, "tie together systems and interfaces that were not specifically designed to interoperate"-- I am not sure if this would be included in a general definition of extension although I assume it would.

I am seeking a general insight into this and perhaps a non-coded example(s) of how this might be practically implemented and why. I will then be able to further research this topic and work on some basic, coded examples to learn from.

Thank-you for your time and any help offered.


10 Years
Discussion Span
Last Post by Narue

There are essentially two ways to extend a language. The first way is through libraries and other modules that don't break the rules of the language but still add functionality. An example of this is the Python/C API that let's you use Python from a C or C++ program.

The second way to extend a language is through a preprocessor. This is when your extensions literally aren't available to the language in question. An example of this would be adding a foreach construct to C++:

vector<int> v;


foreach ( int x in v )
  cout<< x <<'\n';

This involves writing a program that first translates the new construct into valid C++ before passing it on to a C++ compiler.

Votes + Comments
Very Helpful in Answering Post.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.