Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-04

Is there some disadvantages using mode Delphi?

11 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcos Douglas B. Santos

Hi,

I would like to write some packages that should work in FPC and Delphi. I know that I will need to use {mode delphi} to do that.

My ask is: Is there some disadvantages using this mode?

I mean, is there something that we only can do in mode objfpc but not in mode delphi, or is it just about syntax?

Best regards,
Marcos Douglas

Michael Van Canneyt
to Marcos Douglas B. Santos
Marcos Douglas B. Santos wrote 9 lines
Hi, I would like to write some packages that should work in FPC and Delphi. I know that I will need to use {mode delphi} to do that. My ask is: Is there some disadvantages using this mode? I mean, is there something that we only can do in mode objfpc but not in mode delphi, or is it just about syntax?

It is not just about syntax. In ObjFPC mode, the compiler is more strict. (for examlpe: no method parameter names that concide with properties of the object)

Michael.

Marcos Douglas B. Santos
to Michael Van Canneyt

On Sat, Apr 29, 2017 at 2:10 PM, Michael Van Canneyt <

Show quoted text 17 lines
wrote: Hi, > > I would like to write some packages that should work in FPC and Delphi. > I know that I will need to use {mode delphi} to do that. > > My ask is: Is there some disadvantages using this mode? > > I mean, is there something that we only can do in mode objfpc but not in > mode delphi, or is it just about syntax? > It is not just about syntax. In ObjFPC mode, the compiler is more strict. (for examlpe: no method parameter names that concide with properties of the object)

Hmm, right (in fact I like this feature).
So, it is about syntax and strict.

But is there something that I can't do with mode delphi but I can using mode objfpc?
Let me rephrase: Is there some (new cool) feature that only works in mode objfpc?

My concern is make my code cross between FPC and Delphi, but loosing some feature that exists only in FPC.
I would like to know if worth make my code compilable between FPC/Lazarus and Delphi, even if my priority is FPC.

Marcos Douglas

Marco van de Voort
to Marcos Douglas B. Santos: I would like to write some packages that should work in FPC and Delphi. I know that I…

In our previous episode, Marcos Douglas B. Santos said:

Show quoted text 7 lines
I would like to write some packages that should work in FPC and Delphi. I know that I will need to use {mode delphi} to do that. My ask is: Is there some disadvantages using this mode? I mean, is there something that we only can do in mode objfpc but not in mode delphi, or is it just about syntax?

Mostly syntax. Mode objfpc disambiguates a corner case for procedural types with an extra @ for assignment of procedural types, and a few other tightenings.

The proponents of mode objfpc make a big deal out of the differences, but IMHO it is mostly nitpicking. And worse unnecesarily incompatible nitpicking.

Marcos Douglas B. Santos
to Marco van de Voort
Marco van de Voort wrote 17 lines
In our previous episode, Marcos Douglas B. Santos said: > I would like to write some packages that should work in FPC and Delphi. > I know that I will need to use {mode delphi} to do that. > > My ask is: Is there some disadvantages using this mode? > > I mean, is there something that we only can do in mode objfpc but not in > mode delphi, or is it just about syntax? Mostly syntax. Mode objfpc disambiguates a corner case for procedural types with an extra @ for assignment of procedural types, and a few other tightenings. The proponents of mode objfpc make a big deal out of the differences, but IMHO it is mostly nitpicking. And worse unnecesarily incompatible nitpicking.

Good to know.
I remembered something right now: Is there some problem when units mode objfpc have "communication" with units using mode delphi about Unicode?

If I remember well, PChar and even String is different between these modes, right? The compiler will convert strings between them or this is not a problem? Even using LCL?

Sven Barth
to Marcos Douglas B. Santos: On Sat, Apr 29, 2017 at 2:10 PM, Michael Van Canneyt < Hmm, right (in fact I like this…
"Marcos Douglas B. Santos" wrote 19 lines
On Sat, Apr 29, 2017 at 2:10 PM, Michael Van Canneyt < wrote: > > >> Hi, >> >> I would like to write some packages that should work in FPC and Delphi. >> I know that I will need to use {mode delphi} to do that. >> >> My ask is: Is there some disadvantages using this mode? >> >> I mean, is there something that we only can do in mode objfpc but not in >> mode delphi, or is it just about syntax? > > > It is not just about syntax. In ObjFPC mode, the compiler is more strict. > (for examlpe: no method parameter names that concide with properties of

the object)

Show quoted text 5 lines
Hmm, right (in fact I like this feature). So, it is about syntax and strict. But is there something that I can't do with mode delphi but I can using

mode objfpc?

Let me rephrase: Is there some (new cool) feature that only works in mode

objfpc?

The only thing comes to mind would be complex expressions containing inline specializations of generics. Due to the Delphi modes not using the "generic" and "specialize" keywords there is some disambigity that the compiler is not yet able to handle (most of these cases can however be worked around either by explicitly declaring the specializations as types or breaking the expressions up into simpler ones).

Regards,
Sven

Sven Barth
to Marcos Douglas B. Santos: Good to know. I remembered something right now: Is there some problem when units mode…
"Marcos Douglas B. Santos" wrote
On Sat, Apr 29, 2017 at 5:23 PM, Marco van de Voort
> > In our previous episode, Marcos Douglas B. Santos said: > > I would like to write some packages that should work in FPC and

Delphi.

Show quoted text 5 lines
> > I know that I will need to use {mode delphi} to do that. > > > > My ask is: Is there some disadvantages using this mode? > > > > I mean, is there something that we only can do in mode objfpc but not

in

> > mode delphi, or is it just about syntax? > > Mostly syntax. Mode objfpc disambiguates a corner case for procedural

types

> with an extra @ for assignment of procedural types, and a few other > tightenings. > > The proponents of mode objfpc make a big deal out of the differences,

but

Show quoted text 11 lines
> IMHO it is mostly nitpicking. And worse unnecesarily incompatible > nitpicking. Good to know. I remembered something right now: Is there some problem when units mode objfpc have "communication" with units using mode delphi about Unicode? If I remember well, PChar and even String is different between these modes, right? The compiler will convert strings between them or this is not a problem? Even using LCL?

The default string type depends on two different things, namely the mode and the H switch which is by default only set in the Delphi modes. H- means that "String" is "ShortString". H+ means that "String" is "AnsiString" as long as modeswitch UnicodeString is not set (which is for example the case if the mode is DelphiUnicode). However since the latter isn't really recommended yet anyway (since the RTL and especially its classes would still mainly use String=AnsiString) you shouldn't really run into problems there.
The same is true for (P)Char: only if modeswitch UnicodeString is set, then it's an alias for (P)WideChar, otherwise it's an alias for (P)AnsiChar. At least the conversions between the string types are handled by the compiler, only PAnsiChar <=> PWideChar conversions you'd need to do yourself, but the compiler would complain there anyway.

Regards,
Sven

Marcos Douglas B. Santos
to Sven Barth
Sven Barth wrote 16 lines
> If I remember well, PChar and even String is different between these > modes, right? The compiler will convert strings between them or this > is not a problem? Even using LCL? The default string type depends on two different things, namely the mode and the H switch which is by default only set in the Delphi modes. H- means that "String" is "ShortString". H+ means that "String" is "AnsiString" as long as modeswitch UnicodeString is not set (which is for example the case if the mode is DelphiUnicode). However since the latter isn't really recommended yet anyway (since the RTL and especially its classes would still mainly use String=AnsiString) you shouldn't really run into problems there. The same is true for (P)Char: only if modeswitch UnicodeString is set, then it's an alias for (P)WideChar, otherwise it's an alias for (P)AnsiChar. At least the conversions between the string types are handled by the compiler, only PAnsiChar <=> PWideChar conversions you'd need to do yourself, but the compiler would complain there anyway.

Sven, thank you for this explanation.
Well, I will try.

About generics, I'm not using them (yet) so, I won't have problems.

Regards,
Marcos Douglas

Graeme Geldenhuys
to Marcos Douglas B. Santos: On Sat, Apr 29, 2017 at 2:10 PM, Michael Van Canneyt < Hmm, right (in fact I like this…
Marcos Douglas B. Santos wrote
My concern is make my code cross between FPC and Delphi, but loosing some feature that exists only in FPC.

My question is, why do you need Delphi at all? FPC can target more platforms that Delphi, support is better, bugs actually get fixed, and the price of FPC is great. ;-) By only using FPC you can also use the much love (by many) ObjFPC mode.

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
Graeme Geldenhuys
to Marco van de Voort: In our previous episode, Marcos Douglas B. Santos said: Mostly syntax. Mode objfpc…
Marco van de Voort wrote
The proponents of mode objfpc make a big deal out of the differences, but IMHO it is mostly nitpicking. And worse unnecesarily incompatible nitpicking.

For many Delphi is simply not needed, so why would anybody then opt for something other than mode ObjFPC. The objfpc syntax rules make more sense to me, so I consider the more "strict" compiler as a good thing.

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
Marcos Douglas B. Santos
to Graeme Geldenhuys: My question is, why do you need Delphi at all? FPC can target more platforms that Delphi,…
Graeme Geldenhuys wrote 8 lines
On 2017-04-29 21:18, Marcos Douglas B. Santos wrote: > My concern is make my code cross between FPC and Delphi, but loosing some > feature that exists only in FPC. My question is, why do you need Delphi at all? FPC can target more platforms that Delphi, support is better, bugs actually get fixed, and the price of FPC is great. ;-) By only using FPC you can also use the much love (by many) ObjFPC mode.

My priority is FPC. I don't need Delphi, it is just a bonus. I made some packages and some people would like to use on Delphi.

Regards,
Marcos Douglas