[Gambas-user] C like #include for Gambas

Randall Morgan rmorgan62 at ...626...
Mon Jun 11 18:26:07 CEST 2012


Hi Folks,

Thought I would chime in on this issue. As I see it include is a
pre-processing directive. It simply replaces the #include statement with
the contents of an external file. This is a project management
consideration and not a programming paradigm i.e. OOP, Functional,
Procedural, etc.. The include statement in C/C++ was intended to allow
libraries of code to be pulled into the current project. Allowing the
developer to split a large project up into smaller, more manageable files.
While it is used to include header files for libraries, it can be used to
include any text file. It is not a part of the formal language in C/C++.
But is a compiler re-processor.

Contrast this to Ada's use of packages. Package Specifications in Ada at
first seem similar to C header and library files. The major difference is
that packages are a formal part of the Ada language and as such the
compiler knows details about what is in the file and how to use that
information. It is not simply included as text the current compilation. In
fact many Ada compilers use the package specification file to locate and
bind to only the information needed from the package body and any further
dependent data/functions those dependencies may need.

So the question is not one of programming paradigm or language constructs
when it comes to includes. But one of file management. Frankly, I'd love to
see something more inline with Ada Packages placed into Gambas. Then you
could create something that looked like C/C++ includes but would be much
more powerful! However, from a Basic Language stand-point, I don't think
packages are very Basic-like... As for includes, I think this could be a
useful tool for some but wonder why simply refactoring the program into
more manageable class' wouldn't give a better solution. IMHO, doing so
would make the project more maintainable over the long haul....





On Mon, Jun 11, 2012 at 8:42 AM, Jussi Lahtinen <jussi.lahtinen at ...626...>wrote:

> I think this;
>
> "object1.object_within_object.object_within_that_object.method(parameters1,..)"
> can be avoided with good object design. I still can't see real usage for
> #include.
> Also should be noticed that new keywords are justified only if they have
> general usage.
>
> But after all this is decision of Benoit, whether he sees usage for
> #include or not.
>
> Jussi
>
>
>
>
>
> On 11 June 2012 11:10, jm <joem at ...2671...> wrote:
>
> > Hi Bruce,
> >
> > The broadest difference between #include (and its cousins #define,
> > #undefine, #ifdef, #ifndef and #endif) and OO programming is that
> > #include is a preprocessing command that gets to work long before a
> > program gets to run.
> >
> > Using #include and its cousins, the idea is to build big readable
> > programs with the least amount of physical typing effort when used
> > responsibly.
> >
> > I think if it gets pitched as a battle between OO and non-OO
> > programming, the debate is still probably winnable by providing lots of
> > examples where OO programming leads to more work. Basically if all the
> > #include functionality is performed in OO, you got to
> > keep track of objects, and as programs get more complex the syntax will
> > grow which is excessive physical typing and leads to this method of
> > writing programs:
> >
> >
> >
> object1.object_within_object.object_within_that_object.method(parameters1,..)
> >
> > This can also turn into run time expense by having to dereference stuff.
> >
> > [I guess that will in turn let the OO camp will post ample examples of
> > programming that leads to confusion where a use a of a #include
> > is used irresponsibly and has altered programming behaviour in
> > unexpected ways.
> > This in turn will allow the #include camp to post more example where
> > OO behaviour leads to unexpected results confusing the programmer.
> >
> > Lets not go there!!
> > ]
> >
> > Instead of that, it is simpler to put aside the OO v non-OO debate
> > and focus on merits of gambas having pre-processing functions
> > as a subject in its own right.
> >
> > A #include that bolts together programs as needed.
> > When the run button is pressed on the IDE, the idea is that gambas will
> > do the pre-processing and stitch together the files to make a giant file
> > save it to disk as say file_name_to_run.expanded and then run that
> > expanded file.
> >
> > When debugging, there will have to be some kind of option to switch
> > between expanded version of the file and non-expanded version of the
> > file.
> >
> >
> > Any chance of sneaking in this pre-processing
> > productivity enhancing feature? :-)
> >
> >
> >
> >
> > On Sat, 2012-06-09 at 23:30 +0930, Bruce wrote:
> > > On Sat, 2012-06-09 at 13:51 +0100, jm wrote:
> > > > On Sat, 2012-06-09 at 02:45 +0300, Jussi Lahtinen wrote:
> > > > > Maybe I'm just too tired, but I don't understand the point.
> > >
> > > Jussi, maybe I'm just too old as well as tired, but I can't grasp the
> > > point of taking an object oriented language and trying to jam an old
> > > (albeit well tested) non-OO concept into it.
> > >
> > > Joe, I am having some degree of trouble really understanding your value
> > > proposition. Especially the last post (which I have snipped in
> entirety,
> > > sorry). All I can grasp from reading it several times is that you feel
> > > that #include has some productivity value in providing what we call
> > > inheritance and polymorphism.
> > >
> > > I am not trying to put you down but I really can't grasp the ideas of
> > > "thousands" of parameters and "hundreds" of initialisations.
> > >
> > > { We, here at paddys-hill have tens of clients (well a few tens anyway
> )
> > > that use a dozen or so applications, the code base encompasses around
> > > two hundred or so classes and modules organized into around thirty
> > > components and libraries.  The total code size is less than 25,000
> lines
> > > and I would guess that probably 60% or more of that is comments. At a
> > > guess, the "largest" method calls would be 7 parameters, and they are
> > > just convenience calls to a class constructor.  By far the "largest"
> > > chunk of code is a library that downloads the text of around 40 web
> > > pages a day (about 40,000 text lines), parses them, normalises them and
> > > uploads them to the central database. I just checked and it's 6345
> lines
> > > of code, so about 2400 working lines, which are mainly involved in text
> > > parsing (things like discerning "Mac Donald" and "MacDonald" or "Miss
> > > Jane O'Donnel" and "Ms Jan ODonnell" are the same names). The primary
> > > application that uses this library runs once a day and adds about 1200
> > > rows to a central postgresql database and can update anywhere between 2
> > > and 10,000 other rows.  It takes "about" 10 minutes.  The central
> > > database has just over 3.2 million rows, the clients each have a
> > > sub-mirrored database of who-knows-what size.}
> > >
> > > Anyway, I hope you can see from the above {} that those numbers you are
> > > using are fairly un-emotive to the reader.
> > >
> > > regards
> > > Bruce
> > >
> > >
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------------
> > > Live Security Virtual Conference
> > > Exclusive live event will cover all the ways today's security and
> > > threat landscape has changed and how IT managers can respond.
> Discussions
> > > will include endpoint security, mobile security and the latest in
> malware
> > > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > > _______________________________________________
> > > Gambas-user mailing list
> > > Gambas-user at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> >
> ______________________________________________________________________________
> > > This message has been checked for viruses and spam by Armourplate
> > > http://www.armourplate.com, the email archiving, anti virus and anti
> > spam
> > > service from Corpex.
> >
> >
> >
> >
> ______________________________________________________________________________
> > This message has been checked for viruses and spam by Corpex using
> > the ArmourPlate Anti Virus and Anti Spam Scanning Service.
> > To find out more and see our email archiving service see
> > http://www.armourplate.com or call Corpex on UK 0845 050 1898.
> >
> >
> >
> ------------------------------------------------------------------------------
> > Live Security Virtual Conference
> > Exclusive live event will cover all the ways today's security and
> > threat landscape has changed and how IT managers can respond. Discussions
> > will include endpoint security, mobile security and the latest in malware
> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
If you ask me if it can be done. The answer is YES, it can always be done.
The correct questions however are... What will it cost, and how long will
it take?



More information about the User mailing list