Wouldn't it be a great thing to be able to extand a compiler. so if we wanted to "add" a feature to a compiler we just "inherit" and add new feartures?
-
-
Shrage wrote:Wouldn't it be a great thing to be able to extand a compiler. so if we wanted to "add" a feature to a compiler we just "inherit" and add new feartures?
Have a look around the MONO project for the sources to their C# and VB compilers.
-
Oh, thanks, checking it.....
-
Where can i find information about MONO?
Added: i see http://www.mono-project.com/About_Mono -
i"m still looking for any easy way to extent the C# or VB# language, for example the foreach statment is just a keyword that creates normal C# or VB code but it saves you from having to write it out it does it for you at compile time, i would like to add such keywords my self. it's actually like having a macro, which looks for specific keywords at compile time and replaces that keyword with real code.
-
The for each keyword isnt translated in to "normal" vb / c# its converted in to MSIL - along with everything else.
I think I ssee what it is you wanto to do but I'm not sure its possible, especially if you are wanting it all to play nicely with visual studio. If you dotn mind writing all your code in notepad then there is no reason you could now invent your own keywords and then somehow pre-process your files to search-and-replace your keywords with the appropriate code, and then compile.
-
So it's realy a feature in VS i'm asking for. To allow somehow to specify a keyword which will represent several steps in the language i'm working in (Be it C# or VB).
-
You should take a look at the video archives for a talk with Kang Su Gatlin (The C++ Product Manager and C++ God) on "Phoenix," next-generation compiler. If I remember correctly, he does discuss some of what you are talking about... too bad the video is short and what is being discussed is still a little ways off.
-
Shrage wrote:Wouldn't it be a great thing to be able to extand a compiler. so if we wanted to "add" a feature to a compiler we just "inherit" and add new feartures?
Isn't that what the whole C++ language is about? Like C, you create your own functions, which look like keywords to the casual user, then add a bunch of macros which you can name any way you please, all to the end effect of completely confusing someone trying to learn the language on their own.
If you wanted, you could write up some asm code, put that inside a function and call it like a keyword.
I think the concept of "keyword" in C/C++ is a misnomer anyway. Having hundreds of arcane, idiosyncratic functions spread across library after library does NOT make a language easier to learn. Then, having vendor extensions (see Borland products for this one) makes it even more muddled.
It is akin to making up a bunch of words in English (or a language of your choice!) and you either have to take the code "on faith" or dig through header files to find the definition if you want to figure it out on any kind of deep level. Yes, I know this is the whole "black box" approach we all dream of, but sometimes its a pain in the ***.
You can't read code like the olden days, because now you have forms that are event driven, and the function blocks are connected back to the form. But if you tried to read the code straight through, its a mess.
-
In Visual Studio 2005, we have these things called "snippets" that let you insert a chunk of code into the file with minimal key presses. They are extensibile so you can write your own.
Poke around on MSDN and you should see something like that.
-
Almost everyone that I've ever spoken to about the subject will tell you that it is a fundamentally bad idea to "extend" the compiler; it is far better to try and extend the language though the use of the language.
The problem with throwing a few new features into the compiler is that those 'features' will almost always already be catered for. It also makes creating compatible compilers difficult because your changes might not be documented well and just generally adds bloat and time to anyone re-implementing it. Worst still it makes your code extremely locked in to that one compiler on that one platform.
It is one thing to create a new language, it is completely another to go messing in something already standardised (like C#, C and C++ are).
-
Sampy wrote:
In Visual Studio 2005, we have these things called "snippets" that let you insert a chunk of code into the file with minimal key presses. They are extensibile so you can write your own.
Poke around on MSDN and you should see something like that.
Yeah, I have seen them they are not good, not good at all. Macros are wonderful because you can optimise while still hiding your functions, with snippets the code remains visible and complex. Instead of being able to just go ENTERCRITICALSECTION(p) you end up with
void EnterCriticalSection(ptr p)
{
Console.WriteLine("This is not valid C# and I don't care!");
}
I know macros have lots of negatives but lets not forget just how frigging fast and easy to read they make code.
-
The reason why i'm asking for it is because, while i was watching the LINQ video, i was thinking to my self that most of new ideas to a language is that the compilter does something which would take a lot for you to write your self. so not that you couldn't do it before but that it does is automatically for you. so i'm thinking if a compiler keywrod could be extended by the users it could lead to nore new ideas
-
Manip wrote:I know macros have lots of negatives but lets not forget just how frigging fast and easy to read they make code.
As long as you don't have to go back and read somebody else's handiwork. -
While I was writing the previous post i see there was added some responses that make sense, the argument about standardizing is correct but still...J. That's the problem with balancing flexibility and consistency.
-
Shrage wrote:
The reason why i'm asking for it is because, while i was watching the LINQ video, i was thinking to my self that most of new ideas to a language is that the compilter does something which would take a lot for you to write your self. so not that you couldn't do it before but that it does is automatically for you. so i'm thinking if a compiler keywrod could be extended by the users it could lead to nore new ideas
But then you get into issues of optimization potentially...depending on how you extend the keyword. Plus, if you start down the path of "keyword overloading" what ends up happening is that unless you have your extension well documented, someone may not know the difference between the standard usage and your definition. Although I suppose you could technically resolve this with a namespace somehow.
Edit: Plus, to write an effective compiler extension, you'd have to have access to some of the compilers inner workings...and with propietary products, that may not be possible. -
So in other words most ideas can't be created because we are waiting for out bosses to implement it so we all be consitent and have a well documentation? maybe socialogy comes also into the picture ha?
-
What exactly were you planning on doing? If you're able to give us some info, perhaps we can give you an alternate way to implement it?
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.