[fpc-pascal] WHY compiler should be public?

2013-10-24 Thread Xiangrong Fang
Hi,

First of all, I did some research and found this:

http://free-pascal-general.1045716.n5.nabble.com/Compiler-Warning-Constructor-should-be-public-td2825747.html

But that did not convince me. So here is my situation and question.

I have the following case:

TBase = class
public
  constructor Create; //VER-0
end;

TDerived = class(TBase)
private
  constructor Create(param1); //VER-1
public
  constructor Create; reintroduce;//VER-0'
  constructor Create(param1, param2); //VER-2
  constructor Create(param1, param2, param3); //VER-3
end;

My purpose is that while using TDerived, only VER-2
and VER-3 of the constructors should be used, VER-0
and VER-1 are used INTERNALLY by VER-2 and VER-3 and
should NOT be used publicly.

As restricted by the "rule of OOP", you cannot make a
method which is public in base class private in descendants,
I plan to do the following:

1) reintroduce a Create (without param), which just throw
an exception explaining that this MUST NOT be called directly.
Meanwhile, use "inherited Create" internally in other versions
of the constructors.

2) Make VER-1 private so that it cannot be called outside.

Now the compiler throw a warning that constructor should be
public.

In the post I referred, Graeme explained that:

==
Your code is flawed. Object Pascal is quite clear regarding
visibility rules. TObject has a Public constructor. You can
only raise the visibility from there, not reduce visibility.

Imagine how confusing it will be if you code was a library
of some sorts and other developers had to use it. In a
inherited class, you have public visibility to the constructor
or some other method, and then suddenly in the descendant class
the methods are hidden from the developer??  Not a good idea.
==

I don't understand this, because to me, the VER-1 constructor is
introduced in TDerived, make it non-public does NOT reduce the
visibility of VER-0 constructor, hence is not a violation of
visibility rules, is it???

Thanks!
Xiangrong
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Namespaces Support

2013-10-24 Thread Fabrício Srdic
With the new namespace support feature, will the fpc standard and base
units be structured into packages?

e.g types -> system.types; winsock -> windows.winsock; winmouse ->
windows.winmouse


2013/10/24 Michael Van Canneyt 

>
>
> On Thu, 24 Oct 2013, Sven Barth wrote:
>
>  Am 23.10.2013 16:34, schrieb Graeme Geldenhuys:
>>   Michael, how Delphi-compatible is it?  In Delphi I can use (maybe
>> not the best example) the reference
>>   Forms.Application and in the project compiler settings I can say if
>> it is the VCL or the FMX namespace, so it
>>   knows at compile time which Application global variable to use.  I
>> personally haven't used namespaces, but during
>>   recent tiOPF discussions, such an example was presented to me - for
>> use in a future tiOPF v4 branch (where
>>   namespaces will be used to differentiate between FMX, VCL etc. LCL
>> and fpGUI probably too).
>>
>> Specifying default namespaces (which was AFAIK introduced with XE2) is
>> not yet supported in FPC though it's definitely planned
>> to add support for this. Otherwise namespace support should be compatible
>> to Delphi 2009.
>>
>
> Thanks for confirming my statements :)
>
> Michael.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Using arm-embedded-fpc

2013-10-24 Thread Koenraad Lelong

op 23-10-13 21:51, Florian Klämpfl schreef:

Am 23.10.2013 20:01, schrieb Michael Ring:

This article describes what build-id does:

https://fedoraproject.org/wiki/Releases/FeatureBuildId

your fix should get applied to trunk, the gnu-build section should end
up somewhere, best place is flash, it will not get used anyway.


Well, the best would be if it ended up nowhere because it eats only
flash memory.


Hi,

I modified t_embed.pas to not include that line in link.res :
.note.gnu.build-id : { *(.note.gnu.build-id) } >flash

But I'm unable to locate where that '--build-id' is generated for the 
linker-commandline. If that is removed (only for arm-embedded ?), the 
build-id will not be generated, so no wasted memory.


Regards,

Koenraad.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] DataSet.Locate: different behaviour between FPC 2.6.2 and 2.7.1 (rev. 2013/09/01)

2013-10-24 Thread LacaK

silvioprog  wrote / napísal(a):

Hello,

This morning, I compiled a code using FPC (Windows, rev. 2013/09/01), 
after that, my tests using dataset.locate has stopped.


The Locate method locates record, even when it does not exists. The 
problem occurs only with varchar fields, in integer fields it works fine.


In attachment I'm sending a small project to reproduce it. Here in my 
machine I made two tests, please see the log below:


Result in FPC 2.6.2:

test.exe
output: N
output: N

Result in FPC 2.7.1:

test.exe
output: N
output: Y

Can you test it in FPC from trunk?
I guess, that root of this problem is same like in bug report: 
http://bugs.freepascal.org/view.php?id=25016

For sorting/locating are used these string comparasion function:
 AnsiCompareText resp. AnsiCompareStr
Can you test directly  these functions in any simple string comparation 
test ?

I expect, that these functions will return wrong results ?
(may be that string encoding enters into play also? ...  )
-Laco.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Namespaces Support

2013-10-24 Thread Michael Van Canneyt



On Thu, 24 Oct 2013, Sven Barth wrote:


Am 23.10.2013 16:34, schrieb Graeme Geldenhuys:
  Michael, how Delphi-compatible is it?  In Delphi I can use (maybe not the 
best example) the reference
  Forms.Application and in the project compiler settings I can say if it is 
the VCL or the FMX namespace, so it
  knows at compile time which Application global variable to use.  I 
personally haven't used namespaces, but during
  recent tiOPF discussions, such an example was presented to me - for use 
in a future tiOPF v4 branch (where
  namespaces will be used to differentiate between FMX, VCL etc. LCL and 
fpGUI probably too).

Specifying default namespaces (which was AFAIK introduced with XE2) is not yet 
supported in FPC though it's definitely planned
to add support for this. Otherwise namespace support should be compatible to 
Delphi 2009.


Thanks for confirming my statements :)

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Namespaces Support

2013-10-24 Thread Sven Barth

Am 23.10.2013 16:34, schrieb Graeme Geldenhuys:
Michael, how Delphi-compatible is it?  In Delphi I can use (maybe not 
the best example) the reference Forms.Application and in the project 
compiler settings I can say if it is the VCL or the FMX namespace, so 
it knows at compile time which Application global variable to use.  I 
personally haven't used namespaces, but during recent tiOPF 
discussions, such an example was presented to me - for use in a future 
tiOPF v4 branch (where namespaces will be used to differentiate 
between FMX, VCL etc. LCL and fpGUI probably too).
Specifying default namespaces (which was AFAIK introduced with XE2) is 
not yet supported in FPC though it's definitely planned to add support 
for this. Otherwise namespace support should be compatible to Delphi 2009.


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Namespaces Support

2013-10-24 Thread Graeme Geldenhuys


Michael, how Delphi-compatible is it?  In Delphi I can use (maybe not 
the best example) the reference Forms.Application and in the project 
compiler settings I can say if it is the VCL or the FMX namespace, so 
it knows at compile time which Application global variable to use.  I 
personally haven't used namespaces, but during recent tiOPF 
discussions, such an example was presented to me - for use in a future 
tiOPF v4 branch (where namespaces will be used to differentiate 
between FMX, VCL etc. LCL and fpGUI probably too).


How do you tell FPC which namespace a project is using?

Regards,
 - Graeme -



On Wednesday 23/10/2013 at 09:40, Michael Van Canneyt  wrote:

It already has.



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal