I am in the middle of writing a much longer post about variations and recent additions to Pascal syntax in Delphi, Oxygene and Lazarus, but at the same time I also decided to start on the process of migrating some of my code to Lazarus and FPC. In the process I have hit upon a snag.
Ever since I discovered that Delphi 7 (SEVEN!) supported “dotted unit names”, I have adopted this style of unit naming in my own code organisation. In Delphi 7 this incurred some less than desirable behaviours in the IDE, since the support for dotted unit names was at that time a little… preliminary.
Sadly, this means that – as far as I can tell – none of my existing units can be used “as-is” in Lazarus and FPC. There is no support for dotted unit names there, not even with FPC set to “Delphi” syntax parsing.
At first I thought this meant that my Lazarus/FPC ambitions were stalled at a disappointingly early stage.
However, not to be deterred I quickly I found that several suggestions have already been made as to how FPC might go about implementing dotted unit names, some of which aim to improve on the approach in Delphi (though in Delphi mode I would expect things to behave in as Delphi-like a way as possible, obviously).
Then I found that some support in this area has already made it’s way into the latest development version of the FPC compiler.
All I need to do now is figure out how to get Lazarus working with this later, pre-release build of the FPC compiler (something which I gather is possible, just not “plug-and-play”). I also need to be a little cautious as, being pre-release, whatever form the dotted unit name support in the current FPC trunk takes, it could still change.
Tags: fpc, lazarus, namespaces
-
Hm. I don’t think using dots in Unit-Names makes much sense.
All it does is to create additional ambiguities for the parser and to the reader
of your code whenever you prefix a type with a Unit-Name.
Why don’t you just use CamelCase or underscores?-
If you only use CamelCase for long unit names one can’t quickly see which part of the unit name is only a prefix and which is relevant in my current namespace. They are used in Delphi, Java, C#, … and in my opinion this has many advantages.
Underscores? Do you mean this serious? For external API identifiers this is ok, but for identifiers in own code? omg… in my opinion code with underscores looks really dirty.
-
-
-
Getting Lazarus to work (on Windows at least) is as simple as:
- Getting a copy of the fpc source somewhere using svn
- Compiling this code (starting with the old compiler version should work)
- Pointing to the new compiler and source in the lazarus compiler options
- Rebuild Lazarus -
Oops : Getting Lazarus to work with fpc trunk, I meant.
-
I’m not completely sure, but I guess & symbol isn’t included in FPC 2.6.0 release also.
Like:
var
&Type: integer; // though it works in 2.7.1You can check it also.
-
If you find something out, please keep
http://wiki.freepascal.org/delphi_language_features_which_fpc_does_not_have
up to date.
-
-
Did you try the 1.1 nightly builds with fpc
2.6.1? -
Actually, they support the dotted names of units in FPC 2.7.1. But you’ve to download and build it yourself from sources:
http://www.freepascal.org/develop.var
I’ve found out that FPC 2.7.1 has some bug fixes too.-
Sorry, I’ve written the answer without having read up your message.
-
-
This new release also supports the Java Virtual Machine and Dalvik targets, so the RemObjects Oxygene now has a free competitor.
-
GNAT also has JVM and .NET targets. One more free competitor: https://libre.adacore.com/
-
-
You always get the latest snapshot of FPC/Lazarus here:
ftp://newwiki.freepascal.org/pub/lazarus/snapshots/
I can recommend: Lazarus-1.1-38611-fpc-2.7.1-20120911-win32.exe
-
You have to keep in mind that FPC 2.6.0 was released at the beginning of 2012. Even more it was branched last year in July/August, so many of the more intrusive features (regarding compiler code) were not merged to that branch (some smaller ones were included in 2.6.1 and thus will be part of 2.6.2). Features that are only supported in 2.7.1 for example are – as you noticed – dotted unit names and the code page aware string.
Just in case: if you heavily use generics in your Delphi code you should use 2.7.1 as 2.6.0 is not nearly as compatible as 2.7.1 is (though things like constraints and generic methods are still missing and inline specialization is not yet working as flawless as possible – I’m working on them
).Regards,
Sven -
Have a look at codeTyphon. Has Lazarus+FreePascal+Tools+Free Components packages+Free Libraries and is normaly build from the latest fpc / lazarus trunk.
Hope it helps
cu Ha-Joe
-
-
Pingback from Te Waka o Pascal · ReverseBytes() on 20 Sep 2012 at 09:31
Comments are now closed.



DelphiFeeds
29 comments