Please someone explain this to me

classic Classic list List threaded Threaded
53 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Juha Manninen
On Wed, Feb 10, 2016 at 9:12 PM, Anthony Walter <[hidden email]> wrote:
> And could the IDE be enhanced to should which unit is
> ultimately including a file? Obviously the CodeTools already knows, it was
> able to deduce the identifier exists and that it has a declaration by
> looking through the units in the uses clause in the current unit. Couldn't
> something therefore display the unit name in IDE, possibly in the include
> file's source code tab (e.g. system.pas - dynlibh.inc)?

Maybe you did not fully understand what the MainUnit directive does.
It allows you to jump between the Pascal unit and the include file in
any situation, just as if they were one single file.
It works also if you opened first an include file from a search window.
The other way around (unit -> include file) it works even without a
MainUnit directive.
Thus, Lazarus editor fully understands include files unlike Delphi' editor.

In other words you can always do Ctrl-Shift-Up in a method / function
and it does the right thing.
You don't need to worry about if your cursor is on a unit or include
file source.

Juha
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Anthony Walter-3
Juha,

Okay then, maybe everyone should make a mental note and remember add the MainUnit directive to the include files they are editing if it doesn't already exist.

But to ask again, what's the purpose of using include files for the interface section of units when most everything in the interface sections remain unchanged among different platforms? Surely we can move all those the parts back to the unit interface sections. Perhaps if you want to match up a single interface declaration with a several include implementations, I can see that as one method of organization, but wouldn't {$region names} in the interface declarations {$endregion} would be an improvement over many interface section include files? This way I can actually scroll through the interface, ctrl+f through the interface, and not be forced to ctrl+enter on interface section includes to see what is being declared.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Anthony Walter-3
Oh and when the MainUnit directive is included at the top of an include file, how does this affect include files where the declaration is another include files, or include files which next other include files?

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Mattias Gaertner
In reply to this post by Sven Barth-2
> Sven Barth <[hidden email]> hat am 10. Februar 2016 um 15:09
> geschrieben:
> [...]
> > The {%...} directive is a comment in other contexts and can be used safely.
>
> What about include files included by other include files?

That is no problem for the MainUnit directive.
The directive tells the codetools the default start file of the scattered unit.
If the IDE has parsed a unit which uses the include file, the MainUnit directive
is ignored.
If a file is included by multiple units, you can give a common unit.

Basically it is just a convenient fallback.

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Graeme Geldenhuys-6
In reply to this post by Michael Van Canneyt
On 2016-02-10 19:20, Michael Van Canneyt wrote:
> You just need to look at the system or sysutils units from recent delphis to
> see why include files are the better option,


As someone that doesn't have access to recent Delphi versions, would you
mind sharing a small example if you can. I'm not at all surprised by
your comment though. From the messages I have seen about Delphi these
days, not many customers are happy with Delphi's "progress". It sounds
like every release is more like a patch-job to get the next set of
bullet points filled for the next release. No regard for the language or
quality control.

Regards,
  - Graeme -


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Graeme Geldenhuys-6
In reply to this post by Anthony Walter-3
On 2016-02-10 19:12, Anthony Walter wrote:
> I think the thing is I can't help but feel there should be a better system
> for organizing implementations for different systems.

Often some clever usage of design patterns can help, but more often than
not, using include files are just a faster and easier solution to
implement. Make no mistake, include files (when used correctly) is a
pretty powerful option too.

Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

dmitry boyarintsev
In reply to this post by Graeme Geldenhuys-6
On Wed, Feb 10, 2016 at 3:32 PM, Graeme Geldenhuys <[hidden email]> wrote:
On 2016-02-10 19:20, Michael Van Canneyt wrote:
> You just need to look at the system or sysutils units from recent delphis to
> see why include files are the better option,
As someone that doesn't have access to recent Delphi versions, would you
mind sharing a small example if you can.

It would be odd if they're using includes heavily.

It feels like namespaces should've resolved the problem.
Thus includes are replaced by namespaces, since it **should** keep unit-like code structure.

thanks,
Dmitry


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Graeme Geldenhuys-6
In reply to this post by Juha Manninen
On 2016-02-10 19:45, Juha Manninen wrote:
> Thus, Lazarus editor fully understands include files unlike Delphi' editor.

The knock-on affect of include files, is that pascal parsers are much
more complex to write. Luckily we already have quite a few pascal
parsers available, which already work with include files and search
paths etc.

Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Anthony Walter-3
What about the interface section includes and {$region} option I described. Does anyone care to discuss that option? Please go back a few messages and read what I wrote.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Tomas Hajny-2
On Wed, February 10, 2016 22:04, Anthony Walter wrote:
> What about the interface section includes and {$region} option I
> described.
> Does anyone care to discuss that option? Please go back a few messages and
> read what I wrote.

I don't get your $region idea, but as a maintainer of one of the FPC
targets, I can tell you that there are differences also in the interface
sections. Just as an example - unit system needs to combine parts which
are completely common (solved using common include files) with parts which
are platform-specific (take e.g. the DirectorySeparator or LineEnding as
examples). Sometimes there are differences at the target level, sometimes
at platform level, sometimes it makes sense to use a common include file
for a set of targets sharing a common set of characteristics (various MS
Windows targets or Unix targets) in order to simplify the maintenance,
etc. Trying to cover that in one common place would result in something
completely unreadable and unmaintainable - actually much worse compared to
the current situation.

Tomas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Marco van de Voort
In our previous episode, Tomas Hajny said:
> at platform level, sometimes it makes sense to use a common include file
> for a set of targets sharing a common set of characteristics (various MS
> Windows targets or Unix targets) in order to simplify the maintenance,
> etc. Trying to cover that in one common place would result in something
> completely unreadable and unmaintainable - actually much worse compared to
> the current situation.

Indeed, the include stuff is not a linear thing. Generic Unix includes
include (are parameterized) by target specific includes like the earlier
named ptypes.inc.

And then you get to the bit that the syscall targets are switchable to libc
etc.

The original design document for the *nix RTL (originally (c) dec 2002) already
had a section about why includefiles:

http://www.stack.nl/~marcov/unixrtl.pdf

One thing to particularly highlight: many *nix includefiles are used in the
/implementation/ of units below the baseunix unit level, while they only
  become public on the unixtype/baseunix level and below (see pic in above
doc)

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Sven Barth-2
In reply to this post by Anthony Walter-3

Am 10.02.2016 21:03 schrieb "Anthony Walter" <[hidden email]>:
> But to ask again, what's the purpose of using include files for the interface section of units when most everything in the interface sections remain unchanged among different platforms? Surely we can move all those the parts back to the unit interface sections. Perhaps if you want to match up a single interface declaration with a several include implementations, I can see that as one method of organization, but wouldn't {$region names} in the interface declarations {$endregion} would be an improvement over many interface section include files? This way I can actually scroll through the interface, ctrl+f through the interface, and not be forced to ctrl+enter on interface section includes to see what is being declared.

Looks like you haven't actually looked at how the RTL is structured. It is the way it is for a reason and that is both maintainability and extensibility and yes that also includes the interface. You just need to look at the TJumpBuf record used for setjump()/longjump(), it must be different for each target processor and I honestly don't want that clutter in the interface section, because when you need to work at those parts you'll lose the overview and code folding won't help you then.
In short: the RTL will stay as it is, because it's a proven design without better alternatives available.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Anthony Walter-3
For those who didn't understand what I meant by using regions in the interface section rather than include files, here is an image of what is essentially in SysUtils currently:


Notice the unit file is opened the almost none of what it declares is visible. Instead the declarations are hidden in layers of header include files. This makes it difficult to open a file and see what functions, variables, classes, or types are available and can be used. And I might add that this is problem isn't exclusive to the SysUtils unit.

Now here is an example where the interface section includes are moved to regions:


Notice you can actually browse through the types and other declarations by simply scrolling down. I understand there might be situations where the interface of a unit might differ per platform, but surely those situations are in the minority, and they could either be placed in {$IFDEF} directives or just those parts could be put in include files. As it is right now nearly everything is is include files and nested include files making browsing source code declarations more difficult than it should be.

It seems like this {$I sysinth.inc} for a header and {$I sysint.inc} for an implementation harkens to C headers and C implementations, something which Pascal is supposed to have done away with.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Michael Van Canneyt


On Wed, 10 Feb 2016, Anthony Walter wrote:

> For those who didn't understand what I meant by using regions in the
> interface section rather than include files, here is an image of what is
> essentially in SysUtils currently:

You are forgetting that not everyone uses Lazarus. The RTL is part of Free
Pascal.

For RTL work, I never use lazarus, but a plain old text editor, joe.
It doesn't know regions, it doesn't know mainunit etc.

The RTL is organized for the benefit of its maintainers, not the users.
It's a proven design since 20 years as explained by Marco and Sven.


The fact that you're the first to complain in 20 years (at least I cannot
remember any others, and I've been around for a while) gives you an
indication of the relative importance  of your problem.

Lazarus IDE shows a tooltip when you hover over an identifier with the mouse.
I suspect it will take one on the team less than 10-minutes to add the unit
name to the tooltip, in addition to the package and source file name.

Which is, after all, your original problem which is then solved ?

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Michael Van Canneyt
In reply to this post by Anthony Walter-3


On Wed, 10 Feb 2016, Anthony Walter wrote:

> What about the interface section includes and {$region} option I described.
> Does anyone care to discuss that option? Please go back a few messages and
> read what I wrote.

It is not an option.

As said: not everyone uses lazarus.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Michael Van Canneyt
In reply to this post by Graeme Geldenhuys-6


On Wed, 10 Feb 2016, Graeme Geldenhuys wrote:

> On 2016-02-10 19:20, Michael Van Canneyt wrote:
>> You just need to look at the system or sysutils units from recent delphis to
>> see why include files are the better option,
>
>
> As someone that doesn't have access to recent Delphi versions, would you
> mind sharing a small example if you can. I'm not at all surprised by
> your comment though. From the messages I have seen about Delphi these
> days, not many customers are happy with Delphi's "progress". It sounds
> like every release is more like a patch-job to get the next set of
> bullet points filled for the next release. No regard for the language or
> quality control.

I cannot share code, obviously, but I'll say that the code is a big mess of
IFDEFS, used in what seems to me an inconsistent manner (if there is any logic, I fail
to see it). Lazarus has understanding of IFDefs, but the Delphi IDE does
not (just as it does not understand include files), killing the code
navigation, making it hard to navigate or understand these unit.

I normally do not visit these units, so it doesn't harm me, but when I by
accident ended up there I remarked it...
I think the problem is more on the poor guys that must maintain it :)

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Anthony Walter-3
Michael, a question: 

How much of the interface section of units differ per platform? Is it 1% of the code? Is it 5% of the code? With the xml2 unit it's 0%, yet all of the declarations are nested in several layers of include files:


At what point does putting every interface declaration a {$i includemeh.inc} stop making sense?

Okay, so why do I care? Because I want to be able to read what "stuff" is in a unit by the normal means, and that is to scroll through the declarations of a unit and not be forced to open 40 or more {$i includemeh.inc} files. I want to be able to Ctrl+F in a file and find stuff. I appreciate being able to just read interface declarations to learn/understand what exactly a unit is declaring. Multiple nested includes and no real unit interface declarations is to antithetical most all users ability to learn or understand what is available.

With regards to regions and the RTL, if you for some reason are not using Lazarus they don't hurt anything. Instead they would act like a comment saying "Hey, these declarations are implemented in sysint.inc", which has the same impact as saying {$i sysinth.inc}. The difference is you can actually read the declarations.

And then there is the LCL, which seems to have borrowed the idea of {$i includemeh.inc}. The first declarations of the Controls unit does a {$I controlconsts.inc} and simply lists constant component message identifiers. Why does this need to be an include file? Put it in the Controls unit interface section, and if you want throw a region around it as a comment. You get the added bonus to be able to fold if you're using Lazarus, but if not, hey you get a nice comment.

I have a feeling that if I ran some analytics on the interface section of the RTL I would find > 99.5% of the interface section declarations remain the same across all platforms. I also have the feeling that if an accurate 99.5% analysis was presented here some of you would remain adamant that unit interface declarations should NOT contain actual interface declarations, rather multiple nested include files should contain them.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Sven Barth-2
In reply to this post by Anthony Walter-3


Am 11.02.2016 00:23 schrieb "Anthony Walter" <[hidden email]>:
>
> For those who didn't understand what I meant by using regions in the interface section rather than include files, here is an image of what is essentially in SysUtils currently:
>
> http://cache.getlazarus.org/images/sysutils-include.gif
>
> Notice the unit file is opened the almost none of what it declares is visible. Instead the declarations are hidden in layers of header include files. This makes it difficult to open a file and see what functions, variables, classes, or types are available and can be used. And I might add that this is problem isn't exclusive to the SysUtils unit.
>
> Now here is an example where the interface section includes are moved to regions:
>
> http://cache.getlazarus.org/images/sysutils-region.gif
>
> Notice you can actually browse through the types and other declarations by simply scrolling down. I understand there might be situations where the interface of a unit might differ per platform, but surely those situations are in the minority, and they could either be placed in {$IFDEF} directives or just those parts could be put in include files. As it is right now nearly everything is is include files and nested include files making browsing source code declarations more difficult than it should be.
>
> It seems like this {$I sysinth.inc} for a header and {$I sysint.inc} for an implementation harkens to C headers and C implementations, something which Pascal is supposed to have done away with.

This won't be changed. Period.
These units are not this way for the sake of browsing, but for the sake of maintainability.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Adriaan van Os-2
In reply to this post by Michael Van Canneyt
Michael Van Canneyt wrote:

> he fact that you're the first to complain in 20 years (at least I cannot
> remember any others, and I've been around for a while) gives you an indication of the relative importance  of your problem.

I do share Anthony's (strong) dislike of include files (but I am not complaining about it).

> The RTL is organized for the benefit of its maintainers, not the users.
> It's a proven design since 20 years as explained by Marco and Sven.

The maintainers can choose whatever they like best.

Regards,

Adriaan van Os


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Please someone explain this to me

Anthony Walter-3
In reply to this post by Sven Barth-2
This won't be changed. Period.

Sven, not to be argumentative, but you do get that for a long time programmers have learned how to write code and use libraries by examining them? My goal is simply to make it easier for the people who would want to pick up and start using Lazarus. Organizing things better for the general developer population, and I'm not just referring to only source code organization, is something I honestly hope this community considers important. I believe that point should be a consideration not just for beginners, but also for the mass of professionals.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
123