Re: [fpc-devel] type question

2006-10-14 Thread Christian Iversen
On Sunday 15 October 2006 00:42, peter green wrote:
> > In the case of wrapper integers in records, are 4-byte records handled as
> > efficiently by the compiler as 4-byte integers? I suspect it's
> > some radically
> > different code that handles it.
>
> test it?

That would require me to actually do something and not just talk about 
it... ;-)

(but yes, I am going to test it :)

-- 
Regards,
Christian Iversen
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: [fpc-devel] type question

2006-10-14 Thread peter green

> In the case of wrapper integers in records, are 4-byte records handled as
> efficiently by the compiler as 4-byte integers? I suspect it's
> some radically
> different code that handles it.
test it?


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


Re: [fpc-devel] type question

2006-10-14 Thread Peter Vreman

At 23:00 14-10-2006, you wrote:

On Saturday 14 October 2006 17:38, Peter Vreman wrote:
> > On Saturday 14 October 2006 15:55, Marc Weustink wrote:
> >> Hi,
> >>
> >> if I define 2 types like:
> >>
> >> type
> >>   MyA = type string;
> >>   MyB = type string;
> >>
> >> are MyA and MyB considered as the same type ?
> >
> > No, you are explicitly marking them as a new type. This is a very cool
> > feature
> > of Pascal you wont find in many other languages.
> >
> > (For instance, you could use it to create a new integer-type for little-
> > and
> > big-endian numbers, ensuring that you _never_ directly assign a
> > little-endian
> > number to a big-endian one, or vice versa)
>
> For the compiler the types are not equal anymore, but they are still
> compatible for implicit type conversion. This has mainly impact on
> overload choosing and parameter passing. Normal assignments using ':=' are
> not affected because of the still available implicit type conversion.

I really feel there should be a way to make two types completely incompatible.

How exactly does the compiler figure out the rules for implicit conversion?

In the case of wrapper integers in records, are 4-byte records handled as
efficiently by the compiler as 4-byte integers? I suspect it's some radically
different code that handles it.


Only by making it a record. Conversion of atomic types 
(string,integer,etc) are always handled internally by the compiler.



Peter

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


Re: [fpc-devel] type question

2006-10-14 Thread Christian Iversen
On Saturday 14 October 2006 17:38, Peter Vreman wrote:
> > On Saturday 14 October 2006 15:55, Marc Weustink wrote:
> >> Hi,
> >>
> >> if I define 2 types like:
> >>
> >> type
> >>   MyA = type string;
> >>   MyB = type string;
> >>
> >> are MyA and MyB considered as the same type ?
> >
> > No, you are explicitly marking them as a new type. This is a very cool
> > feature
> > of Pascal you wont find in many other languages.
> >
> > (For instance, you could use it to create a new integer-type for little-
> > and
> > big-endian numbers, ensuring that you _never_ directly assign a
> > little-endian
> > number to a big-endian one, or vice versa)
>
> For the compiler the types are not equal anymore, but they are still
> compatible for implicit type conversion. This has mainly impact on
> overload choosing and parameter passing. Normal assignments using ':=' are
> not affected because of the still available implicit type conversion.

I really feel there should be a way to make two types completely incompatible.

How exactly does the compiler figure out the rules for implicit conversion?

In the case of wrapper integers in records, are 4-byte records handled as 
efficiently by the compiler as 4-byte integers? I suspect it's some radically 
different code that handles it.

-- 
Regards,
Christian Iversen
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] type question

2006-10-14 Thread Marc Weustink
Florian Klaempfl wrote:
> Marc Weustink schrieb:
>> Next question: Should operator overloading be possible on such types ?
> 
> Yes.

Then I think I found a bug, see 7610

Marc


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


Re: [fpc-devel] type question

2006-10-14 Thread Florian Klaempfl

Marc Weustink schrieb:

Next question: Should operator overloading be possible on such types ?


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


RE: [fpc-devel] type question

2006-10-14 Thread peter green
one trick if you wan't to keep a type but redefine the operators on it is to
wrap it in a single element record.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Marc
> Weustink
> Sent: 14 October 2006 16:42
> To: FPC developers' list
> Subject: Re: [fpc-devel] type question
>
>
> Peter Vreman wrote:
> >> On Saturday 14 October 2006 15:55, Marc Weustink wrote:
> >>> Hi,
> >>>
> >>> if I define 2 types like:
> >>>
> >>> type
> >>>   MyA = type string;
> >>>   MyB = type string;
> >>>
> >>> are MyA and MyB considered as the same type ?
> >> No, you are explicitly marking them as a new type. This is a very cool
> >> feature
> >> of Pascal you wont find in many other languages.
> >>
> >> (For instance, you could use it to create a new integer-type
> for little-
> >> and
> >> big-endian numbers, ensuring that you _never_ directly assign a
> >> little-endian
> >> number to a big-endian one, or vice versa)
> >
> > For the compiler the types are not equal anymore, but they are still
> > compatible for implicit type conversion. This has mainly impact on
> > overload choosing and parameter passing. Normal assignments
> using ':=' are
> > not affected because of the still available implicit type conversion.
>
> I came to this when I wanted to do operator overloading on them. The
> compiler complained that you cannot overload for equal types.
>
> So I wanted first to know if it are equal types or not.
>
> Next question: Should operator overloading be possible on such types ?
>
> Marc
>
> ___
> 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] type question

2006-10-14 Thread Marc Weustink
Peter Vreman wrote:
>> On Saturday 14 October 2006 15:55, Marc Weustink wrote:
>>> Hi,
>>>
>>> if I define 2 types like:
>>>
>>> type
>>>   MyA = type string;
>>>   MyB = type string;
>>>
>>> are MyA and MyB considered as the same type ?
>> No, you are explicitly marking them as a new type. This is a very cool
>> feature
>> of Pascal you wont find in many other languages.
>>
>> (For instance, you could use it to create a new integer-type for little-
>> and
>> big-endian numbers, ensuring that you _never_ directly assign a
>> little-endian
>> number to a big-endian one, or vice versa)
> 
> For the compiler the types are not equal anymore, but they are still
> compatible for implicit type conversion. This has mainly impact on
> overload choosing and parameter passing. Normal assignments using ':=' are
> not affected because of the still available implicit type conversion.

I came to this when I wanted to do operator overloading on them. The
compiler complained that you cannot overload for equal types.

So I wanted first to know if it are equal types or not.

Next question: Should operator overloading be possible on such types ?

Marc

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


Re: [fpc-devel] type question

2006-10-14 Thread Peter Vreman
> On Saturday 14 October 2006 15:55, Marc Weustink wrote:
>> Hi,
>>
>> if I define 2 types like:
>>
>> type
>>   MyA = type string;
>>   MyB = type string;
>>
>> are MyA and MyB considered as the same type ?
>
> No, you are explicitly marking them as a new type. This is a very cool
> feature
> of Pascal you wont find in many other languages.
>
> (For instance, you could use it to create a new integer-type for little-
> and
> big-endian numbers, ensuring that you _never_ directly assign a
> little-endian
> number to a big-endian one, or vice versa)

For the compiler the types are not equal anymore, but they are still
compatible for implicit type conversion. This has mainly impact on
overload choosing and parameter passing. Normal assignments using ':=' are
not affected because of the still available implicit type conversion.



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


Re: [fpc-devel] type question

2006-10-14 Thread Ivo Steinmann

Marc Weustink wrote:

program TypeTest;
{$mode objfpc}{$h+}

type
  TMyA = type String;
  TMyB = type String;

var
  A: TMyA;
  B: TMyB;
  S: String;

begin
  S := 'Some value';
  A := S;
  B := S;

  S := A;
  S := B;

  A := B;
  B := A;
end.

  
Well, assign works, but if you use them as var Parameters it works not! 
It's also nice if you have got overloaded functions.


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


Re: [fpc-devel] type question

2006-10-14 Thread Marc Weustink
Christian Iversen wrote:
> On Saturday 14 October 2006 15:55, Marc Weustink wrote:
>> Hi,
>>
>> if I define 2 types like:
>>
>> type
>>   MyA = type string;
>>   MyB = type string;
>>
>> are MyA and MyB considered as the same type ?
> 
> No, you are explicitly marking them as a new type. This is a very cool 
> feature 
> of Pascal you wont find in many other languages.
> 
> (For instance, you could use it to create a new integer-type for little- and 
> big-endian numbers, ensuring that you _never_ directly assign a little-endian 
> number to a big-endian one, or vice versa)
> 
>> Should it be allowed to assign a variable of type MyA to a variable of
>> type MyB ?
> 
> No.
> 
>> IIRC, the use of = type  creates a new type.
> 
> That's right.

OK, thanks for confirming my thoughts.
In an attempt to make some use of it, I tried the following, and it
compiles without a problem (also tried with Integer).
>From this it seems that for FPC it doesn't matter if it is "typed" or not.

Marc


program TypeTest;
{$mode objfpc}{$h+}

type
  TMyA = type String;
  TMyB = type String;

var
  A: TMyA;
  B: TMyB;
  S: String;

begin
  S := 'Some value';
  A := S;
  B := S;

  S := A;
  S := B;

  A := B;
  B := A;
end.


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


Re: [fpc-devel] type question

2006-10-14 Thread Christian Iversen
On Saturday 14 October 2006 15:55, Marc Weustink wrote:
> Hi,
>
> if I define 2 types like:
>
> type
>   MyA = type string;
>   MyB = type string;
>
> are MyA and MyB considered as the same type ?

No, you are explicitly marking them as a new type. This is a very cool feature 
of Pascal you wont find in many other languages.

(For instance, you could use it to create a new integer-type for little- and 
big-endian numbers, ensuring that you _never_ directly assign a little-endian 
number to a big-endian one, or vice versa)

> Should it be allowed to assign a variable of type MyA to a variable of
> type MyB ?

No.

> IIRC, the use of = type  creates a new type.

That's right.

-- 
Regards,
Christian Iversen
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] type question

2006-10-14 Thread Marc Weustink
Hi,

if I define 2 types like:

type
  MyA = type string;
  MyB = type string;

are MyA and MyB considered as the same type ?
Should it be allowed to assign a variable of type MyA to a variable of
type MyB ?
IIRC, the use of = type  creates a new type.
Or am I wrong ?

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


[fpc-devel] Bug: 07281 Memleak with Interfaces

2006-10-14 Thread Franz Schober








Hello Developers,

 

are there any news regarding bug 07281?

 

I think this bug is closely related to bug 7209.

 

The problem is that it is not possible with any compilers
greater 2.0.2 to compile

a memory stable program that uses interfaces.

 

We would like to release Zeos Dataset components for
2.0.4, but as Zeos make intensive

use of interfaces, it is not possible to make a
program that runs memory stable with it. 

 

Please help us.

 

Zeos is a mature set of database components allowing
access to e.g. 

MySQL, PostgreSQL, Firebird/Interbase, Oracle with
the same set of components.

 

 

Bug 07281 contains a heap trace and short program
showing the problem.

 

Greetings, 

 

 Franz

 






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