Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Graeme Geldenhuys
On Thu, Jul 17, 2008 at 2:55 AM, Joao Morais [EMAIL PROTECTED] wrote:
 Just if you want to know my humble opinion: your statement isn't fair. You
 know a property isn't a variable, so don't assume it will behave like that.
 If you want a property function as a variable, eg reading and writing a
 class member directly, do use a public variable instead. Fpc core is doing a
 really nice job, improving and extending the compiler in their spare time,
 helping all developers writing better source code. This one is a good
 sample. They don't deserve such comment.

My bad.  I had one of those off developer days yesterday. ;-)  And it
seemed everything I tried under FPC 2.3.1 did not work as expected,
where they did in 2.2.3 and prior.

eg:  I inherited some code from another project that I now need to
amend to compile with FPC 2.3.1. Yes it's not the best looking code,
but it works and I'm pushed for time, so code clean-up needs to wait.

Simple one liners like the following:

   inc(FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots,
itm.CountSlots);
or
   FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots += itm.CountSlots;

now has to change to this ugly line...

   FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots :=
  FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots +
itm.CountSlots;


Maybe it's just me, but the first two lines are much easier to read
and less prone to typing errors.

And yes, I really do appreciate what the FPC core team are doing. They
have done a wonderful job so far, and the reason our company will
continue using FPC in the future. Unfortunately I'm not a compiler
developer, so I can only comment from an applications developer point
of view.


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Graeme Geldenhuys
On Wed, Jul 16, 2008 at 5:37 PM, Jonas Maebe [EMAIL PROTECTED] wrote:
 Indeed. I've checked the code and properties are explicitly not allowed for
 the C-style operators. The reason is that the x+=y is translated into
 x:=x+y at the parser level rather than at the lexical level. This means
 that in case x is a property, at the point that this transformation is
 performed the compiler already resolved it into the setter property (so it
 can no longer access the getter).

Sorry if the following sounds stupid, but I'm a applications
developer, not a compiler developer. I do not know or understand the
internals of a compiler.

So is what you mentioned above by design, or an oversight?  In normal
code like x := x+y  you are allowed to use properties or variables.
So surely the += operator which translates to x := x+y should also
be allowed to use properties.

We spoke earlier in another thread about hidden exceptions (rules)
which will just complicate things in the long run. Well to me, this
looks like one of those exceptions which the FPC core would like to
prevent.


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Micha Nelissen

Graeme Geldenhuys wrote:

Simple one liners like the following:

   inc(FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots,
itm.CountSlots);
or
   FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots += itm.CountSlots;

now has to change to this ugly line...

   FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots :=
  FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots +
itm.CountSlots;


Or:

tempRow := FDayList[itm.WeekDayNum].Rows[itm.Timeslot];
tempRow.AvailableSlots := tempRow.AvailableSlots + itm.CountSlots;

Assuming .Rows[X] results in a class instance.

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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Micha Nelissen

Jonas Maebe wrote:
Indeed. I've checked the code and properties are explicitly not allowed 
for the C-style operators. The reason is that the x+=y is translated 
into x:=x+y at the parser level rather than at the lexical level. This 


So I guess the obvious question is: would it be risky to change that so 
it parses it at the lexical level? :-)


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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Jonas Maebe


On 17 Jul 2008, at 08:41, Graeme Geldenhuys wrote:


Simple one liners like the following:

  inc(FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots,
itm.CountSlots);
or
  FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots +=  
itm.CountSlots;


now has to change to this ugly line...

  FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots :=
 FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots +
itm.CountSlots;


Or

with FDayList[itm.WeekDayNum].Rows[itm.Timeslot] do
  AvailableSlots:= AvailableSlots+itm.CountSlots;


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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Daniël Mantione



Op Thu, 17 Jul 2008, schreef Micha Nelissen:


Graeme Geldenhuys wrote:

Simple one liners like the following:

   inc(FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots,
itm.CountSlots);
or
   FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots += 
itm.CountSlots;


now has to change to this ugly line...

   FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots :=
  FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots +
itm.CountSlots;


Or:

tempRow := FDayList[itm.WeekDayNum].Rows[itm.Timeslot];
tempRow.AvailableSlots := tempRow.AvailableSlots + itm.CountSlots;

Assuming .Rows[X] results in a class instance.


Even shorter:

with itm do
  with FDayList[WeekDayNum].Rows[Timeslot] do
AvailableSlots:=AvailableSlots+CountSlots;

Daniël___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Jonas Maebe


On 17 Jul 2008, at 08:48, Graeme Geldenhuys wrote:

On Wed, Jul 16, 2008 at 5:37 PM, Jonas Maebe [EMAIL PROTECTED] 
 wrote:
Indeed. I've checked the code and properties are explicitly not  
allowed for

the C-style operators. The reason is that the x+=y is translated into
x:=x+y at the parser level rather than at the lexical level. This  
means
that in case x is a property, at the point that this transformation  
is
performed the compiler already resolved it into the setter property  
(so it

can no longer access the getter).


Sorry if the following sounds stupid, but I'm a applications
developer, not a compiler developer. I do not know or understand the
internals of a compiler.

So is what you mentioned above by design, or an oversight?


I'm fairly certain that the C-style operators were implemented long  
before most, if any, Delphi feature had been implemented (possibly  
even before Delphi had properties).



We spoke earlier in another thread about hidden exceptions (rules)
which will just complicate things in the long run. Well to me, this
looks like one of those exceptions which the FPC core would like to
prevent.


Feel free to file a bug report.


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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Jonas Maebe


On 17 Jul 2008, at 09:09, Daniël Mantione wrote:


Even shorter:

with itm do
 with FDayList[WeekDayNum].Rows[Timeslot] do
   AvailableSlots:=AvailableSlots+CountSlots;


Even shorter:

with itm, FDayList[WeekDayNum].Rows[Timeslot] do
   AvailableSlots:=AvailableSlots+CountSlots;

But nested or combined with-statements can be dangerous in case there  
are multiple fields with the same name in the different records/ 
classes/objects.



Jonas___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Graeme Geldenhuys
On Thu, Jul 17, 2008 at 9:05 AM, Micha Nelissen [EMAIL PROTECTED] wrote:
 Simple one liners like the following:

   inc(FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots,
 itm.CountSlots);
 or
   FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots +=
 itm.CountSlots;

 now has to change to this ugly line...

   FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots :=
  FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots +
 itm.CountSlots;

 Or:

 tempRow := FDayList[itm.WeekDayNum].Rows[itm.Timeslot];
 tempRow.AvailableSlots := tempRow.AvailableSlots + itm.CountSlots;


And that's what I changed it to, just after I posted my message.  :-)
Either way, it's still two lines of code compared to one.  But, it will do.


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Graeme Geldenhuys
On Thu, Jul 17, 2008 at 9:07 AM, Micha Nelissen [EMAIL PROTECTED] wrote:
 Jonas Maebe wrote:

 Indeed. I've checked the code and properties are explicitly not allowed
 for the C-style operators. The reason is that the x+=y is translated into
 x:=x+y at the parser level rather than at the lexical level. This

 So I guess the obvious question is: would it be risky to change that so it
 parses it at the lexical level? :-)


My question too   Would somebody be so kind as to explain the
difference to me?  As I mentioned before, I'm not a compiler
developer.


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Graeme Geldenhuys
On Thu, Jul 17, 2008 at 9:09 AM, Jonas Maebe [EMAIL PROTECTED] wrote:
 Or

 with FDayList[itm.WeekDayNum].Rows[itm.Timeslot] do
  AvailableSlots:= AvailableSlots+itm.CountSlots;


No that's one language construct I wish Object Pascal could do
without!  I personally hate the 'with' statement, and it's hard to
debug.

At least FPC with mode objfpc had the common sense NOT to allow the
following (which I believe is still allowed in Delphi).  Also tooltip
evaluation/debugging doesn't work with 'with' statements in Lazarus or
Delphi.


type
  MyClass = class(TObject)
  ...
  public
property MyName: String .
  end;

procedure MyClass.Foobar;
var
  MyName: string;
begin
  with self do
  begin
 MyName := 'hello';  // Are we using e local var MyName or MyClass.MyName??
  end;
end;



Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Graeme Geldenhuys
On Thu, Jul 17, 2008 at 9:38 AM, Graeme Geldenhuys
[EMAIL PROTECTED] wrote:
 At least FPC with mode objfpc had the common sense NOT to allow the
 following (which I believe is still allowed in Delphi).  Also tooltip
 evaluation/debugging doesn't work with 'with' statements in Lazarus or
 Delphi.


 type
  MyClass = class(TObject)
  ...
  public
property MyName: String .
  end;

 procedure MyClass.Foobar;
 var
  MyName: string;
 begin
  with self do
  begin
 MyName := 'hello';  // Are we using e local var MyName or MyClass.MyName??
  end;
 end;


BTW:
I know that's a horrible example, but I think you get my point
regarding the MyName variable/field.   :-)


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Graeme Geldenhuys
2008/7/17 Jonas Maebe [EMAIL PROTECTED]:
 Even shorter:

 with itm, FDayList[WeekDayNum].Rows[Timeslot] do
   AvailableSlots:=AvailableSlots+CountSlots;


Arg [grinding my teeth]
Nested with statements are even worse than my previous complaint!  ;-)


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Daniël Mantione



Op Thu, 17 Jul 2008, schreef Graeme Geldenhuys:


On Thu, Jul 17, 2008 at 9:09 AM, Jonas Maebe [EMAIL PROTECTED] wrote:

Or

with FDayList[itm.WeekDayNum].Rows[itm.Timeslot] do
 AvailableSlots:= AvailableSlots+itm.CountSlots;



No that's one language construct I wish Object Pascal could do
without!  I personally hate the 'with' statement, and it's hard to
debug.


It is simply a tradeoff between readability and understandability. A line 
a:=a+1 is much more clean than a few lines of pointer dereferences, array 
indexes and records subscripts. The downside is that it becomes harder to 
track where the variables come from. Huge with bodies can be confusing. 
The programmer decides, after all writing readable code is an art.


Daniël___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Micha Nelissen

Graeme Geldenhuys wrote:

My question too   Would somebody be so kind as to explain the
difference to me?  As I mentioned before, I'm not a compiler
developer.


Very rudimentary:

source --lexer-- tokens --parser-- tree --code gen-- code

- source is the .pas file etc.
- tokens are things like '{', '}', identifiers, etc.
- tree is using the grammatical rules to form a tree with 'statement' 
nodes, 'if' nodes, 'for' nodes, etc.

- code is the destination language (assembly usually).

There are more steps in the compiler, but this is the basic idea.

Apparantly in the tokens, the property has already been parsed to its 
getter function. (Making some assumptions here, I don't know fpc that well).


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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Boian Mitov

This is if you like the risk of using with ;-)
This works until somebody changes the FDayList[WeekDayNum].Rows[Timeslot] to 
contain CountSlots property, and all your code is broken ;-) .

If you want stable code, never use the with or else ... ;-)

 With best regards,
   Boian Mitov


Mitov Software
http://www.mitov.com



- Original Message - 
From: Jonas Maebe [EMAIL PROTECTED]

To: FPC developers' list fpc-devel@lists.freepascal.org
Sent: Thursday, July 17, 2008 12:15 AM
Subject: Re: [fpc-devel] C style operator doesn't work with properties in 
2.3.1




On 17 Jul 2008, at 09:09, Daniël Mantione wrote:


Even shorter:

with itm do
 with FDayList[WeekDayNum].Rows[Timeslot] do
   AvailableSlots:=AvailableSlots+CountSlots;


Even shorter:

with itm, FDayList[WeekDayNum].Rows[Timeslot] do
   AvailableSlots:=AvailableSlots+CountSlots;

But nested or combined with-statements can be dangerous in case there
are multiple fields with the same name in the different records/
classes/objects.


Jonas___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel 


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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Michael Schnell



If you want stable code, never use the with or else ... ;-)

I did learn this even in the early Delphi days ;)

Moreover AFAIK, even the newest Delphi does not show the value of 
variables that are qualified using a with. So you even can't debug the 
broken code decently.


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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Michael Schnell

Boian Mitov wrote:
There are a lot of fans of with ;-) . I have been burned however 
long time ago. Now when I get a new code from somebody, my first task 
is to remove any with from it ;-). As far as I am concerned with 
is a Pascal design bug. May the guy who invented with track with 
bugs for eternity ;-) .
I completely agree. We use a lot of (mostly commercial) Delphi 3rd party 
components. All of them bought with source code to be more safe. Lot's 
of them make heavy use of with. Very annoying !


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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Boian Mitov
You will hardly find any in our components ;-) . Not as long as I run the 
company, and do most of the work. I even plan to add preprocessor to catch 
missed with during the build process.


 With best regards,
   Boian Mitov


Mitov Software
http://www.mitov.com



- Original Message - 
From: Michael Schnell [EMAIL PROTECTED]

To: FPC developers' list fpc-devel@lists.freepascal.org
Sent: Thursday, July 17, 2008 2:02 AM
Subject: Re: [fpc-devel] C style operator doesn't work with properties in 
2.3.1



I completely agree. We use a lot of (mostly commercial) Delphi 3rd party 
components. All of them bought with source code to be more safe. Lot's of 
them make heavy use of with. Very annoying !


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


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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Martin Friebe
Or Add a Method to the target object. (as long as it is part of your 
code base, or can be modified by you)

and then do

FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlotsInc(itm.CountSlots);

In the class that defines
 property AvailableSlot;
you can add
 procedure AvailableSlotsInc(n : Integer);

Same for include, exclude, and all the others.

Best Regards
Martin


Jonas Maebe wrote:


On 17 Jul 2008, at 08:41, Graeme Geldenhuys wrote:


Simple one liners like the following:

  inc(FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots,
itm.CountSlots);
or
  FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots += 
itm.CountSlots;


now has to change to this ugly line...

  FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots :=
 FDayList[itm.WeekDayNum].Rows[itm.Timeslot].AvailableSlots +
itm.CountSlots;


Or

with FDayList[itm.WeekDayNum].Rows[itm.Timeslot] do
  AvailableSlots:= AvailableSlots+itm.CountSlots;


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

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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Martin Friebe

From my understanding ( the fpc team probably can to more exact):

* lexical level
This would be like a simple Find and Replace on the text. This would 
work with anything, as it doesn't know what it is translating.

(It is very similar to a (non-buildin) C-preprocessor)

* parser level
The parser will likely translate the source into a structure of objects
 a := a + 1
becomes
 ObjectAssignmenOp
 LeftHandTerm = ObjVariable a
 RightHandTerm = ObjExpression ( ObjAddition: Op1 = Variable a; 
Op2= 1 )


If that happens to += then a+=1
 ObjectAssignmenOpIncr
 LeftHandTerm = ObjVariable
 RightHandTerm = ObjExpression

if the left hand term is a property, then because it is the left hand 
(which will be assigned to), the lefthand term becomes the property-setter.

The ObjectAssignmenOpIncr then has no reference to the property-getter.


Graeme Geldenhuys wrote:

On Thu, Jul 17, 2008 at 9:07 AM, Micha Nelissen [EMAIL PROTECTED] wrote:
  

Jonas Maebe wrote:


Indeed. I've checked the code and properties are explicitly not allowed
for the C-style operators. The reason is that the x+=y is translated into
x:=x+y at the parser level rather than at the lexical level. This
  

So I guess the obvious question is: would it be risky to change that so it
parses it at the lexical level? :-)




My question too   Would somebody be so kind as to explain the
difference to me?  As I mentioned before, I'm not a compiler
developer.


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel
  

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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Joao Morais

Graeme Geldenhuys wrote:

So is what you mentioned above by design, or an oversight?  In normal
code like x := x+y  you are allowed to use properties or variables.
So surely the += operator which translates to x := x+y should also
be allowed to use properties.


Except that, when using variables, the first and the second x are the 
same entity.


I think what you need is a new feature. If the statement before the += 
token is a property, instead of a variable, the compiler converts it 
into one getter and one setter, and after that use them to perform the 
calculation.


--
Joao Morais
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Illegal type conversion: enumeration type to TObject

2008-07-17 Thread Florian Klaempfl

Sean McIlwain schrieb:
The following code fails to compile in Delphi mode but successfully 
compiles in objfpc mode:


type
 TEnum = (a, b, c);
var
 AValue: TEnum;
 AObject : TObject;
implementation

initialization
 AObject := TObject(AValue);



Could this be supported in the Delphi mode as well?


Please submit a bug report.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Illegal type conversion: enumeration type to TObject

2008-07-17 Thread Micha Nelissen

Sean McIlwain wrote:

initialization
 AObject := TObject(AValue);

Could this be supported in the Delphi mode as well?


Forgot to take your pills today? ;)

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


[fpc-devel] [patch] minor changes to fcl-db codegen unit fpccgtiopf.pp

2008-07-17 Thread Graeme Geldenhuys
This needs to be applied from the trunk directory.  All very minor changes...

Changes include

* Minor classname adjustment
* Query.SQL.Text   ---  Query.SQLText otherwise the setter method is
bypassed, which could contain custom code.
* uses clause cleanup


Regards,
 - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
Index: packages/fcl-db/src/codegen/fpcgtiopf.pp
===
--- packages/fcl-db/src/codegen/fpcgtiopf.pp	(revision 11386)
+++ packages/fcl-db/src/codegen/fpcgtiopf.pp	(working copy)
@@ -125,8 +125,8 @@
 constructor TTiOPFCodeOptions.Create;
 begin
   inherited Create;
-  FListAncestorName:='TTiObjectList';
-  AncestorClass:='TTiObject';
+  FListAncestorName:='TtiObjectList';
+  AncestorClass:='TtiObject';
   ObjectClassName:='MyObject';
   FVisitorOptions:=[voRead,voCreate,voDelete,voUpdate];
   FClassOptions:=[caCreateList,caListAddMethod,caListItemsProperty];
@@ -185,7 +185,7 @@
 begin
   Result:=inherited GetInterfaceUsesClause;
   If (Result'') then
-Result:=Result+',';
+Result:=Result+', ';
   Result:=Result+'tiVisitor, tiVisitorDB, tiObject';
 end;
 
@@ -701,7 +701,7 @@
 procedure TTiOPFCodeGenerator.WriteSetSQL(Strings : TStrings; Const ASQL : String);
 
 begin
-  Addln(Strings,Format('Query.SQL.Text:=%s;',[ASQL]));
+  Addln(Strings,Format('Query.SQLText:=%s;',[ASQL]));
 end;
 
 procedure TTiOPFCodeGenerator.WriteDeleteVisitor(Strings : TStrings; Const ObjectClassName : String);
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


re: [fpc-devel] Incompatible Types: got untyped expected procedure variable type of procedure(Pointer);Register

2008-07-17 Thread Craig Peterson

 Matthias Gaertner wrote:
I'm getting a Error: Incompatible Types: got untyped expected 
procedure variable type of procedure(Pointer);Register when

compiling the following code.  This happens when using default
parameter values.



Use mode objfpc and CallBack:[EMAIL PROTECTED]


Is there some reason why this can't be handled automatically in Delphi 
mode?  In the example (and every case where it's an issue in our code), 
the callback is a procedure and doesn't return anything, so Callback := 
Proc isn't ambiguous.


Regards,
Craig Peterson
Scooter Software

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


Re: [fpc-devel] Incompatible Types: got untyped expected procedure variable type of procedure(Pointer);Register

2008-07-17 Thread Micha Nelissen

Craig Peterson wrote:

Use mode objfpc and CallBack:[EMAIL PROTECTED]


Is there some reason why this can't be handled automatically in Delphi 
mode?  In the example (and every case where it's an issue in our code), 
the callback is a procedure and doesn't return anything, so Callback := 
Proc isn't ambiguous.


Ambiguity depends on whether it takes parameters or not. Return value 
would be context sensitive. One doesn't want a context sensitive language.


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


Re: [fpc-devel] Incompatible Types: got untyped expected procedure variable type of procedure(Pointer);Register

2008-07-17 Thread Craig Peterson

Micha Nelissen wrote:
Ambiguity depends on whether it takes parameters or not. Return value 
would be context sensitive. One doesn't want a context sensitive language.


The code presented is perfectly valid in Delphi, so it apparently *is* a 
context sensitive language, and I'm sure we're not the only developers 
that appreciate that fact.  The objfpc mode can be as strict as you 
want, but it seems like the Delphi mode should work with all of the 
constructs that Delphi itself allows.  Am I wrong about its intended 
behavior?


Regards,
Craig Peterson
Scooter Software

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


Re: [fpc-devel] Incompatible Types: got untyped expected procedure variable type of procedure(Pointer);Register

2008-07-17 Thread Micha Nelissen

Craig Peterson wrote:

Micha Nelissen wrote:
Ambiguity depends on whether it takes parameters or not. Return value 
would be context sensitive. One doesn't want a context sensitive 
language.


The code presented is perfectly valid in Delphi, so it apparently *is* a 
context sensitive language, and I'm sure we're not the only developers 
that appreciate that fact.  The objfpc mode can be as strict as you 


Yes but this has got nothing to do with original poster's problem :-). 
Original poster's problem is about '= nil', not the more general context 
sensitiveness issue.


want, but it seems like the Delphi mode should work with all of the 
constructs that Delphi itself allows.  Am I wrong about its intended 
behavior?


No, AFAICS it's a bug in fpc's delphi mode.

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


Re: [fpc-devel] Incompatible Types: got untyped expected procedure variable type of procedure(Pointer);Register

2008-07-17 Thread Craig Peterson

 Yes but this has got nothing to do with original poster's problem :-).

Sean (the original poster) is my coworker, so his problem and mine are 
one and the same. ;-)  I'm having a little trouble parsing your 
responses though, so to clarify:


In Delphi, the following code works:

  procedure BtnClick(Sender: TObject = nil);
  ...
  var Callback: TNotifyEvent;
  ...
  Callback := BtnClick;

In FPC, it doesn't, even with $MODE DELPHI.

We consider that a bug in FPC's Delphi mode.  Are we wrong?

Thanks,
Craig

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


Re: [fpc-devel] Incompatible Types: got untyped expected procedure variable type of procedure(Pointer);Register

2008-07-17 Thread Peter Vreman
   Yes but this has got nothing to do with original poster's problem :-).

 Sean (the original poster) is my coworker, so his problem and mine are
 one and the same. ;-)  I'm having a little trouble parsing your
 responses though, so to clarify:

 In Delphi, the following code works:

procedure BtnClick(Sender: TObject = nil);
...
var Callback: TNotifyEvent;
...
Callback := BtnClick;

 In FPC, it doesn't, even with $MODE DELPHI.

 We consider that a bug in FPC's Delphi mode.  Are we wrong?

Please submit bug with compilable sample code without requiring external units.

Peter


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


Re: [fpc-devel] C style operator doesn't work with properties in 2.3.1

2008-07-17 Thread Luca Olivetti
El Thu, 17 Jul 2008 09:15:46 +0200
Jonas Maebe [EMAIL PROTECTED] escribió:

 But nested or combined with-statements can be dangerous in case
 there are multiple fields with the same name in the different

Many, many years ago, I programmed in texas instruments' pascal for the
9995. Of course it wasn't object oriented (almost nothing was at the
time), but it had a short-hand notation for with, like

with a=some.record, a2=some.other.record do
begin
  a.field=a2.field;
  a.other=a2.other
end;

Of course you could also use the standard notation, but this one
avoids the ambiguities.

Bye
-- 
Luca
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Illegal type conversion: enumeration type to TObject

2008-07-17 Thread Michael Van Canneyt


On Thu, 17 Jul 2008, Florian Klaempfl wrote:

 Sean McIlwain schrieb:
  The following code fails to compile in Delphi mode but successfully compiles
  in objfpc mode:
  
  type
  TEnum = (a, b, c);
  var
   AValue: TEnum;
   AObject : TObject;
  implementation
  
  initialization
   AObject := TObject(AValue);
  
  
  
  Could this be supported in the Delphi mode as well?
 
 Please submit a bug report.

Eh ? 
As far as I'm concerned this should not compile in Objfpc mode as well ?

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


Re: [fpc-devel] [patch] minor changes to fcl-db codegen unit fpccgtiopf.pp

2008-07-17 Thread Michael Van Canneyt


On Thu, 17 Jul 2008, Graeme Geldenhuys wrote:

 This needs to be applied from the trunk directory.  All very minor changes...
 
 Changes include
 
 * Minor classname adjustment
 * Query.SQL.Text   ---  Query.SQLText otherwise the setter method is
 bypassed, which could contain custom code.
 * uses clause cleanup

Applied, thank you :-)

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


Re: [fpc-devel] Illegal type conversion: enumeration type to TObject

2008-07-17 Thread Micha Nelissen
Michael Van Canneyt wrote:
  AObject := TObject(AValue);

 Could this be supported in the Delphi mode as well?
 Please submit a bug report.
 
 Eh ? 
 As far as I'm concerned this should not compile in Objfpc mode as well ?

It's a typecast, so then almost anything is allowed, except perhaps if
the size doesn't match.

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


Re: [fpc-devel] Unicode Letters

2008-07-17 Thread theo
ik schrieb:
 In hebrew (at least) the punctuation is a different char that comes
 after the letter, but painted like it was part of the letter, so you
 can parse each word and ignore non letter value (it arrives in
 different range in the unicode table).


   
Yes, the question is: which are non letter values in the upper unicode
ranges?
I've now written some code myself to do this and separate the words.
If you're interested, I can post a download link here.

Thank you
Theo


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


Re: [fpc-devel] Unicode Letters

2008-07-17 Thread Felipe Monteiro de Carvalho
On Wed, Jul 16, 2008 at 4:09 PM, theo [EMAIL PROTECTED] wrote:
 Is there a better way to do what I need?

I think that writing such a routine which compares the char to a table
will be the best solution.

-- 
Felipe Monteiro de Carvalho
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Illegal type conversion: enumeration type to TObject

2008-07-17 Thread Vinzent Höfler

Micha Nelissen wrote:

Michael Van Canneyt wrote:

 AObject := TObject(AValue);

Could this be supported in the Delphi mode as well?

Please submit a bug report.
Eh ? 
As far as I'm concerned this should not compile in Objfpc mode as well ?


It's a typecast, so then almost anything is allowed, except perhaps if
the size doesn't match.


The latter probably being the problem here, sizes of enumeration types 
differ in Delphi and FPC mode.


Apart from that I don't see any sense in such type of a typecast.

If I were to store such things in a generic list data type I would use 
a pointer list, not an object list, if alone to avoid the risk of 
accidentally trying to Free such objects.



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


Re: [fpc-devel] Illegal type conversion: enumeration type toTObject

2008-07-17 Thread Boian Mitov
Now only if we can go ~15 years back in time and tell that to the original 
developers of VCL and things like TStrings and their data type ;-) . 
Unfortunately they take TObject only, and there are a lot of cases when 
casting other data types to it is needed. I wish it was not the case, but it 
is the reality :-( .


 With best regards,
   Boian Mitov


Mitov Software
http://www.mitov.com



- Original Message - 
From: Vinzent Höfler [EMAIL PROTECTED]

To: FPC developers' list fpc-devel@lists.freepascal.org
Sent: Thursday, July 17, 2008 3:12 PM
Subject: Re: [fpc-devel] Illegal type conversion: enumeration type 
toTObject




Apart from that I don't see any sense in such type of a typecast.

If I were to store such things in a generic list data type I would use a 
pointer list, not an object list, if alone to avoid the risk of 
accidentally trying to Free such objects.




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


Re: [fpc-devel] Illegal type conversion: enumeration type toTObject

2008-07-17 Thread Vinzent Höfler

Boian Mitov wrote:
Now only if we can go ~15 years back in time and tell that to the 
original developers of VCL and things like TStrings and their data type 
;-) . Unfortunately they take TObject only, and there are a lot of cases 
when casting other data types to it is needed. I wish it was not the 
case, but it is the reality :-( .


Hmm, point taken. Well, at least TStrings doesn't seem to add any 
functionality to further handle such objects, especially it doesn't 
try Freeing any of them.


- Original Message - From: Vinzent Höfler 
[EMAIL PROTECTED]

To: FPC developers' list fpc-devel@lists.freepascal.org
Sent: Thursday, July 17, 2008 3:12 PM
Subject: Re: [fpc-devel] Illegal type conversion: enumeration type 
toTObject




Apart from that I don't see any sense in such type of a typecast.

If I were to store such things in a generic list data type I would 
use a pointer list, not an object list, if alone to avoid the risk of 
accidentally trying to Free such objects.


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