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.
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.
FPC supports dotted unit names. But Lazarus (or the used FPC version?) does not.
Yep, as I understand it Lazarus 1.0 supports them in the IDE (in the sense that it no longer rejects them in various places as “invalid identifiers”) but the FPC version that is in the release distro (FPC 2.6.0) does not. Dotted unit names is in FPC 2.7.x and is subject to change.
There are daily snapshots of Lazarus with FPC 2.7.1 just google for it. Last time I checked (few months ago) it was pretty much broken but the dotted unit names worked.
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
Yes, simple, but not plug-and-play and quite a few manual steps in the process (the instructions I found included creating a BAT file necessary to compile the compiler). At the time that I came across this I had plenty of other, more important things to do. By the time I’ve done those the feature might be stabilised and part of a more straightforward install (the stabilised part is the most important to me).
I don’t recommend running Lazarus with 2.7.1 for production anyway. (and it will probably remain that way quite a while).
This because 2.7.1 changes things in unicode support (D2009+ like) that Lazarus hasn’t adapted too.
That being said, IMHO dotted units isn’t exactly the nicest feature. One I would gladly do without (yes I know XE2 makes it near mandatory, which is why I’m on XE)
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.1
You can check it also.
Maybe, maybe not. But this feature in Delphi is one of those that breaks the IDE (up to and including XE2 at least) so I never use it (try using Class Completion when your class includes a property that uses the ‘&’ prefix).
I agree. I try to avoid such expressions too.
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
Excellent, thanks for that! 🙂
You might want to take a look at FPCUP – automated command line tool that downloads current FPC & Lazarus from SVN, compiles and installs it – separate from existing installs (snapshots, release builds, other SVNs). Default settings need to be modified to download latest FPC 2.7.1.
http://www.lazarus.freepascal.org/index.php?topic=15919.0
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
I think Codetyphoon is still using Lazarus 0.92 🙁
..probably due for an update soon 🙂
Current CodeTyphon is using this:
Lazarus 1.1.0 Source from SVN 28-7-2012 Rev 38083
FreePascal 2.7.1 Source from SVN 22-7-2012 Rev 21951
Lazarus 0.9.2.9 was last used back in 2010.
http://www.pilotlogic.com/codetyphon/changeslog.txt
CodeTyphon uses Lazarus
see also :
http://www.pilotlogic.com/sitejoom/index.php/forum/forums-general/2253-codetyphon-with-stable-lazarus-1-0
I’ll correct myself, it seems CodeTyphoon rebuilds the latest CSV, just tried it and got Lazarus 1.1
This is getting better and better 🙂
CodeTyphon uses Lazarus 1.1
http://www.pilotlogic.com/sitejoom/index.php/forum/forums-general/2253-codetyphon-with-stable-lazarus-1-0