[Lazarus] Support for dotted unit name

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

[Lazarus] Support for dotted unit name

Kjow
Hi all,

what FPC version support dotted unit name?

>From the wiki: http://wiki.lazarus.freepascal.org/FPC_New_Features_Trunk

"Delphi-like namespaces units
Overview: Support has been added for unit names with dots."

So, I believe that if it refers to trunk, it should be about 2.7.1
I don't understand if it is already implemented or if it will be a
future feature.

Thank you!
Kjow

PS when this feature will be in stable trunk? (approximately)

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Paul Ishenin-2
03.11.2011 16:19, Kjow wrote:

> Hi all,
>
> what FPC version support dotted unit name?
>
>> From the wiki: http://wiki.lazarus.freepascal.org/FPC_New_Features_Trunk
>
> "Delphi-like namespaces units
> Overview: Support has been added for unit names with dots."
>
> So, I believe that if it refers to trunk, it should be about 2.7.1
> I don't understand if it is already implemented or if it will be a
> future feature.

New_Features_Trunk contains new feature of the trunk compiler. If the
feature is present in the released compiler - it should be removed from
there. If the feature is not yet ready - it should not be there.

> PS when this feature will be in stable trunk? (approximately)

Depends on what you understand by "stable trunk".

This feature is already in trunk. You can use units with dots in 2.7.1
and even Lazarus supports them (well, maybe not everywhere).

Best regards,
Paul Ishenin.


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Kjow
2011/11/3 Paul Ishenin <[hidden email]>:
> New_Features_Trunk contains new feature of the trunk compiler. If the
> feature is present in the released compiler - it should be removed from
> there. If the feature is not yet ready - it should not be there.

> Depends on what you understand by "stable trunk".
>
> This feature is already in trunk. You can use units with dots in 2.7.1 and
> even Lazarus supports them (well, maybe not everywhere).
>
> Best regards,
> Paul Ishenin.

Thank you very much :)

Best Regards,
Kjow

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

William Oliveira Ferreira
Sorry about my low knowlegde, maybe i am the most slow-learning mailer
of this list but i don't understand the advantage of using dots on
unit name. Could someon explain it to me?

2011/11/3, Kjow <[hidden email]>:

> 2011/11/3 Paul Ishenin <[hidden email]>:
>> New_Features_Trunk contains new feature of the trunk compiler. If the
>> feature is present in the released compiler - it should be removed from
>> there. If the feature is not yet ready - it should not be there.
>
>> Depends on what you understand by "stable trunk".
>>
>> This feature is already in trunk. You can use units with dots in 2.7.1 and
>> even Lazarus supports them (well, maybe not everywhere).
>>
>> Best regards,
>> Paul Ishenin.
>
> Thank you very much :)
>
> Best Regards,
> Kjow
>
> --
> _______________________________________________
> Lazarus mailing list
> [hidden email]
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>


--
________________________________
William de Oliveira Ferreira
Bacharel em Sistemas de Informação

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Rich Saunders
On 11/3/11 7:03 PM, William Oliveira Ferreira wrote:
> Sorry about my low knowlegde, maybe i am the most slow-learning mailer
> of this list but i don't understand the advantage of using dots on
> unit name. Could someon explain it to me?

Say you use a bunch of units where XXX is defined multiple times, once
in each unit.

If you refer to XXX alone the actual XXX being referred to is determined
by the search logic of the compiler which is governed by the scope rules
within your unit and by the order of the uses clause. So arbitrary
changes in the unit ordering can change the semantics of your code.
 
But if you really want to be sure that UnitX.XXX is the XXX being
referenced you need to refer to XXX with the unit name prefix to ensure
that.

This happens to me when I declare a method of a class as Inc to
increment some field value in the class. Within the Inc method I need to
call System.Inc to actually do the incrementing. Without the System
prefix I would get recursion since the Inc method would call itself.

Rich S.


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

William Oliveira Ferreira
Thanks, becames more clear to me!

2011/11/3, Rich Saunders <[hidden email]>:

> On 11/3/11 7:03 PM, William Oliveira Ferreira wrote:
>> Sorry about my low knowlegde, maybe i am the most slow-learning mailer
>> of this list but i don't understand the advantage of using dots on
>> unit name. Could someon explain it to me?
>
> Say you use a bunch of units where XXX is defined multiple times, once
> in each unit.
>
> If you refer to XXX alone the actual XXX being referred to is determined
> by the search logic of the compiler which is governed by the scope rules
> within your unit and by the order of the uses clause. So arbitrary
> changes in the unit ordering can change the semantics of your code.
>
> But if you really want to be sure that UnitX.XXX is the XXX being
> referenced you need to refer to XXX with the unit name prefix to ensure
> that.
>
> This happens to me when I declare a method of a class as Inc to
> increment some field value in the class. Within the Inc method I need to
> call System.Inc to actually do the incrementing. Without the System
> prefix I would get recursion since the Inc method would call itself.
>
> Rich S.
>
>
> --
> _______________________________________________
> Lazarus mailing list
> [hidden email]
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>


--
________________________________
William de Oliveira Ferreira
Bacharel em Sistemas de Informação

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Mattias Gaertner
In reply to this post by Rich Saunders
On Thu, 03 Nov 2011 19:46:01 -0400
Rich Saunders <[hidden email]> wrote:

> On 11/3/11 7:03 PM, William Oliveira Ferreira wrote:
> > Sorry about my low knowlegde, maybe i am the most slow-learning mailer
> > of this list but i don't understand the advantage of using dots on
> > unit name. Could someon explain it to me?
>
> Say you use a bunch of units where XXX is defined multiple times, once
> in each unit.
>
> If you refer to XXX alone the actual XXX being referred to is determined
> by the search logic of the compiler which is governed by the scope rules
> within your unit and by the order of the uses clause. So arbitrary
> changes in the unit ordering can change the semantics of your code.
>  
> But if you really want to be sure that UnitX.XXX is the XXX being
> referenced you need to refer to XXX with the unit name prefix to ensure
> that.
>
> This happens to me when I declare a method of a class as Inc to
> increment some field value in the class. Within the Inc method I need to
> call System.Inc to actually do the incrementing. Without the System
> prefix I would get recursion since the Inc method would call itself.

This is the explanation for using unitname.identifier, which worked
since many years.

Dotted unit name means dots in the unit name itself. For example
an.example.pas. I don't know a good example.


Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Graeme Geldenhuys
On 4 November 2011 09:17, Mattias Gaertner <[hidden email]> wrote:
> This is the explanation for using unitname.identifier, which worked
> since many years.

I was just about to say the same thing.


> Dotted unit name means dots in the unit name itself. For example
> an.example.pas. I don't know a good example.

I don't see any use for it either. It seems to be one of those things
Borland introduced with or after Delphi 8 (aka Delphi for .NET).
Basically trying to copy features from .NET for no good reason. And we
all know how great an idea that was.


--
Regards,
  - Graeme -


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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

michael.vancanneyt


On Fri, 4 Nov 2011, Graeme Geldenhuys wrote:

> On 4 November 2011 09:17, Mattias Gaertner <[hidden email]> wrote:
>> This is the explanation for using unitname.identifier, which worked
>> since many years.
>
> I was just about to say the same thing.
>
>
>> Dotted unit name means dots in the unit name itself. For example
>> an.example.pas. I don't know a good example.
>
> I don't see any use for it either. It seems to be one of those things
> Borland introduced with or after Delphi 8 (aka Delphi for .NET).
> Basically trying to copy features from .NET for no good reason. And we
> all know how great an idea that was.

Weep, then, because as of Delphi XE2, they started using it a lot.

Michael.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Žilvinas Ledas


On 2011-11-04 10:08, [hidden email] wrote:

>
>
> On Fri, 4 Nov 2011, Graeme Geldenhuys wrote:
>
>> On 4 November 2011 09:17, Mattias Gaertner
>> <[hidden email]> wrote:
>>> This is the explanation for using unitname.identifier, which worked
>>> since many years.
>>
>> I was just about to say the same thing.
>>
>>
>>> Dotted unit name means dots in the unit name itself. For example
>>> an.example.pas. I don't know a good example.
>>
>> I don't see any use for it either. It seems to be one of those things
>> Borland introduced with or after Delphi 8 (aka Delphi for .NET).
>> Basically trying to copy features from .NET for no good reason. And we
>> all know how great an idea that was.
>
> Weep, then, because as of Delphi XE2, they started using it a lot.
>
And, I believe, it will be usefull for JVM port.


Regards,
Žilvinas


> Michael.
>
> --
> _______________________________________________
> Lazarus mailing list
> [hidden email]
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Hans-Peter Diettrich
In reply to this post by William Oliveira Ferreira
William Oliveira Ferreira schrieb:
> Sorry about my low knowlegde, maybe i am the most slow-learning mailer
> of this list but i don't understand the advantage of using dots on
> unit name. Could someon explain it to me?

It's not an advantage, only a relict from the (never finished) .NET
experiment. It's kind of emulation of the .NET namespaces or assemblies,
where e.g. System.System could denote the Delphi System unit in the .NET
namespace (or assembly) System.

As others already pointed out, dotted unit names can cause problems with
Delphi qualified names. Without dotted unit names "a.b.c"
(unit.object.method) is somewhat easy to parse, since only "a" has to be
searched in the used units list. But with dotted names the search also
must try to match "a.b" (or more) with a unit name. You may get wrong
results, when unit "a" contains a record or object variable "b" with
field "c", and a variable "a" in some other unit refers to an record (or
object) with fields "b.c".

There exist more relicts from .NET, like Unicode names for identifiers.
Since Delphi identifiers are case insensitive, the lookup of an
identifier then can be quite time consuming. While with ASCII names only
the "capital" bit must be cleared for all characters, in order to make
an identifier name unique (all uppercase), no such simple mapping exists
for non-ASCII characters. In C or C# all identifiers are case-sensitive,
so that no ToUpper or ToLower are required before the lookup of an
identifier, and consequently it doesn't matter whether an identifier
contains strange characters. IMO it were better to make Delphi
identifier names case sensitive at the same time, at least when they
contain non-ASCII characters.

DoDi


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Graeme Geldenhuys
In reply to this post by michael.vancanneyt
On 4 November 2011 10:08,  <michael.vancanneyt@.....> wrote:
> Weep, then, because as of Delphi XE2, they started using it a lot.

From the CodeRage 6 videos all I could see is that they now
differentiate between VCL (eg: vcl.forms.pas) and FireMonkey (eg:
fm.forms.pas) units.  I don't have a copy of XE2, but other than to
try and prevent confusion in the support forums by now referring to a
specific framework's "forms.pas" unit by pre-pending it with the
framework name.... In what other way are they using it where it is
really useful?  [this is a honest question]



--
Regards,
  - Graeme -


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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

William Oliveira Ferreira
Wait, now i´ve better understand. FPC Team already added this feature to compiler, ok, but, add it just to be delphi XE2 compatible?
________________________________
William de Oliveira Ferreira
Bacharel em Sistemas de Informação



2011/11/4 Graeme Geldenhuys <[hidden email]>
On 4 November 2011 10:08,  <michael.vancanneyt@.....> wrote:
> Weep, then, because as of Delphi XE2, they started using it a lot.

From the CodeRage 6 videos all I could see is that they now
differentiate between VCL (eg: vcl.forms.pas) and FireMonkey (eg:
fm.forms.pas) units.  I don't have a copy of XE2, but other than to
try and prevent confusion in the support forums by now referring to a
specific framework's "forms.pas" unit by pre-pending it with the
framework name.... In what other way are they using it where it is
really useful?  [this is a honest question]



--
Regards,
  - Graeme -


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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Sven Barth
Am 04.11.2011 11:42, schrieb William Oliveira Ferreira:
> Wait, now i´ve better understand. FPC Team already added this feature to
> compiler, ok, but, add it just to be delphi XE2 compatible?

Dotted unit names were already introduced by at least Delphi 2005 (some
sources even report Delphi 7) - Note: I don't count Delphi 8 as this was
a .NET only release.

Regards,
Sven


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Sven Barth
In reply to this post by Hans-Peter Diettrich
Am 04.11.2011 11:15, schrieb Hans-Peter Diettrich:
> William Oliveira Ferreira schrieb:
>> Sorry about my low knowlegde, maybe i am the most slow-learning mailer
>> of this list but i don't understand the advantage of using dots on
>> unit name. Could someon explain it to me?
>
> It's not an advantage, only a relict from the (never finished) .NET
> experiment. It's kind of emulation of the .NET namespaces or assemblies,
> where e.g. System.System could denote the Delphi System unit in the .NET
> namespace (or assembly) System.

I don't think that Embarcadero considers dotted unit names as a relict
as they've improved the concept with a "default namespace" in XE2 (I
don't know whether I personally consider that as a improvement though
^^) and also introduced dotted names for all RTL, VCL and FireMonkey units.

Regards,
Sven


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Rich Saunders
In reply to this post by Mattias Gaertner
On 11/4/11 3:17 AM, Mattias Gaertner wrote:
> Dotted unit name means dots in the unit name itself. For example
> an.example.pas. I don't know a good example.
Well, if unit names are tied to file names and embedded dots are
becoming more common in file names, then I can understand the "pressure"
to relax the unit naming rules to also allow for embedded dots.

But, no, I do not foresee the need in my work.


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Christian-W. Budde
In reply to this post by Mattias Gaertner
Hello,

> This is the explanation for using unitname.identifier, which worked
> since many years.
>
> Dotted unit name means dots in the unit name itself. For example
> an.example.pas. I don't know a good example.

For me, this makes perfect sense, because of many reasons. Here are a
couple.

I work on several open source projects, which have in common that all
these projects are marked with the abbreviation before the actual unit
name. For example with Graphics32 it is 'GR32_'. Replacing the
underscore with a '.' would make it appear more logical from a pascal
point of view (underscores shall be avoided in favor of CamelCase) and
the handling of units look more like records then.

In my second project I have another example where it makes sense from a
hierarchical point of view. There I have implemented dozens of filters,
with lots of optimizations resulting in a vast amount of code. When I
wanted to split this code into several units I thought, that it should
have the name Filters first. But, to give an example, this would result
in 'FiltersButterworth', 'FiltersChebyshev' and 'FiltersBasic'. It just
seems to be odd in the english language, where it would rather be
'ButterworthFilters', 'ChebyshevFilters' and so on.

Separating the names by something like a '.' would make much sense in my
opinion.

I have never used .NET, nor am I a Delphi fan-boy, but I think this
scoping is useful and I hope it will be supported by FPC. It is
discussable, whether it shall be used in Lazarus, but it should be
supported.

        Christian


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Hans-Peter Diettrich
In reply to this post by Sven Barth
Sven Barth schrieb:

> I don't think that Embarcadero considers dotted unit names as a relict
> as they've improved the concept with a "default namespace" in XE2 (I
> don't know whether I personally consider that as a improvement though
> ^^) and also introduced dotted names for all RTL, VCL and FireMonkey units.

Well, so what's the role of "Delphi" at all? What remains is an IDE and
a compiler, with various GUI extensions. Will Lazarus follow this route
- should it ever???

We have enough problems in implementing a VCL compatible LCL, with
attempts to make it compatible with various widgetsets, and with new
Delphi versions. All this could be trashed in an attempt to add
FireMonkey compatibility. It would be better to start a very new project
for that purpose, whose IDE could be based on the LCL, like the Delphi
IDE is based on .NET since D20xx.

DoDi


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Felipe Monteiro de Carvalho
In reply to this post by Hans-Peter Diettrich
On Fri, Nov 4, 2011 at 11:15 AM, Hans-Peter Diettrich
<[hidden email]> wrote:
> There exist more relicts from .NET, like Unicode names for identifiers.

Unlike dots in unit names, this feature is useful for people in a
general way, not just for .Net / Java compatibility. Pretty much every
programmer which isnt fluent in english would benefit from it.

> Since Delphi identifiers are case insensitive, the lookup of an identifier
> then can be quite time consuming.

have you ever run lazarus/test/lazutils/testunicode.lpi ? Or done any
performance tests on the subject?

6 million lower case operations on strings of aprox. 25 utf-8 chars
long take aprox. 1 second.

So I really doubt that any project build process could be slowed
significantly by the cost of doing Unicode lowercase or Uppercase.

The version from iconv is 2,5x slower then the one in LazUtils, but
then it's a choice people can make, use slower iconv or faster Pascal
=)

--
Felipe Monteiro de Carvalho

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Support for dotted unit name

Sven Barth
In reply to this post by Christian-W. Budde
Am 04.11.2011 13:04, schrieb Christian-W. Budde:
> I have never used .NET, nor am I a Delphi fan-boy, but I think this
> scoping is useful and I hope it will be supported by FPC. It is
> discussable, whether it shall be used in Lazarus, but it should be
> supported.

In 2.7.1 this is already supported, so you can play around with it
already (2.6 won't contain it though).

Regards,
Sven

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
123