[Gambas-user] C like #include for Gambas

Rolf-Werner Eilert eilert-sprachen at ...221...
Tue Jun 12 16:30:26 CEST 2012


Am 12.06.2012 13:41, schrieb Benoît Minisini:
> Le 12/06/2012 13:01, jm a écrit :
>> On Tue, 2012-06-12 at 12:03 +0200, Rolf-Werner Eilert wrote:
>>>> You already have at your disposal a program which fully understands
>>>> what to do with #include (and all the other pre-processor directives
>>>> which have been mentioned). Have you tried it out yet?
>>>>
>>>
>>> Is it possible to insert the C pre-processor into the Play-Button
>>> function of the Gambas IDE, maybe the way you can insert filters into
>>> kprinter? That would be ideal here.
>>>
>>> Just an idea... :-)
>>>
>>> Rolf
>>
>> Wow!
>>
>> Thinking about it, that is even more powerful to cooperate
>> with external preprocessor than just adding preprocesor functionality on
>> its own.
>>
>> A simple check box in project properties dialog box to enable/disable
>> preprocessing can turn the feature on/off. Some programs you may just
>> not want to allow preprocessing and so checking it off here will allow
>> the compiler to complain bitterly to go get it fixed.
>>
>

Now, let me add these few thoughts:

>
> I'm talking about code subsitution, not the features currently
> implemented in the Gambas compiler, that just allow compiling one part
> of the code or another.

(Are there any? Didn't even know that...)

> Moreover, preprocessing makes programs mostly unreadable, can create
> very difficult bugs, make the source code impossible to analyze (bye-bye
> automatic completion...), and so on.

Yes, automatic completion would mean browsing all #included files each 
time to search for keywords, but how do IDEs for C programming handle this?

>
> Developing a program is 20% writing it and 80% debugging it. So
> preprocessing makes that worse.

Guess you're darn right here...

There's just one more thing that popped into my mind, isn't it that a 
Gambas class code must adhere to certain rules as to where is what? I 
mean, you must start with variable declaration and then add the 
functions. You cannot declare a public variable at the end of the class, 
right?

So, if you could #include another, say "file" into the code, and this 
file contains variable declarations AND functions, you would get a lot 
of confusion if it was simply concatenated. Instead, an #include 
function would have to interpret the code at least a bit up to the point 
it could distinguish between variable declarations and functions to add 
the variable declarations to the others and the functions to the others 
in the temp file.

And so we are at the point we would have to code that ourselves and 
could not simply re-use the C preprocessor. It would at least be another 
obstacle.

Rolf




More information about the User mailing list