Re: [fpc-pascal] Bug or feature ?

2022-07-27 Thread Sven Barth via fpc-pascal

Am 27.07.2022 um 15:14 schrieb Ched via fpc-pascal:

Hello All,

I have a long code which include lines for writing stuffs into an 
assigned writable text-file F.


   WRITELN(F: 'Hello');

   WRITELN(F, 'Hello');

The code can be compiled with 3.2.2 in i386/windows and i386/linux and 
runs both times at perfection. But... i'm wondering if the first line 
is really legal... Any advice ?


Write(), WriteLn() and WriteStr() (and Str()) allow to adjust the way a 
numerical value is written by using additional parameters delimited by 
colons: VarToOutput:NumChars[:Decimals] (see 
https://www.freepascal.org/docs-html/current/rtl/system/write.html ). 
That it nevertheless compiles correctly and executes as "Writeln(F, 
'Hello')" is due to a bug in the handling of the parameters. So, please 
report a bug with a complete example that should fail.


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


Re: [fpc-pascal] Bug or feature ?

2022-07-27 Thread Ched via fpc-pascal

Le 27.07.2022 à 17:41, DougC via fpc-pascal a écrit :

WRITELN(F: 'Hello');
is not proper Pascal.


Yes, Doug, I agree ; but it is compiled with no warning and runs perfectly. Now, why the compiler do not 
complain... ?


Cheers, Ched'

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Bug or feature ?

2022-07-27 Thread DougC via fpc-pascal
WRITELN(F: 'Hello');

is not proper Pascal.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Bug or feature ?

2022-07-27 Thread Ched via fpc-pascal

Hello All,

I have a long code which include lines for writing stuffs into an assigned 
writable text-file F.

   WRITELN(F: 'Hello');

   WRITELN(F, 'Hello');

The code can be compiled with 3.2.2 in i386/windows and i386/linux and runs both times at perfection. 
But... i'm wondering if the first line is really legal... Any advice ?


Cheers, Ched'.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-14 Thread Elmar Haneke via fpc-pascal



This can't be right, can it?

type
   TBird = class
 procedure Fly;
   end;
   TEagle = TBird; // alias

procedure TEagle.Fly;
begin
end;



It does depend on what you expect an Type-Alias to be.

If you expect the compiler to generate an compatible class then your 
example must not be compilable.


If you expect an alias die make the Typenames "TEagle" and "TBird" 
equivalent it is no problem for the compiler which name you use at what 
place.


In any case I would judge such code as "bad style" - programmers should 
avoid doing so.



Elmar


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-13 Thread Michael Van Canneyt via fpc-pascal



On Sun, 13 Feb 2022, Sven Barth via fpc-pascal wrote:


Personally, I would not allow this.
But Delphi compiles and runs it...


... and Delphi's class completion no longer works in the unit giving a
useless error "expected ';' but '.' found". So it is one of those
Delphi "features" compiling but not usable.


I'm all for forbidding this in objfpc mode.



Then file a bug report for it. Cause it's definitely going to be one of the
low priority things cause it's going to be annoying to fix...


Done:

https://gitlab.com/freepascal.org/fpc/source/-/issues/39576

Maybe someone can check whether Florian's solution really is 'famous last 
words' ;-)

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-13 Thread Florian Klämpfl via fpc-pascal

Am 13.02.2022 um 10:25 schrieb Sven Barth via fpc-pascal:
Michael Van Canneyt via fpc-pascal mailto:fpc-pascal@lists.freepascal.org>> schrieb am 
So., 13. Feb. 2022, 09:47:




On Sun, 13 Feb 2022, Mattias Gaertner via fpc-pascal wrote:

 > On Sat, 12 Feb 2022 12:14:14 +0100 (CET)
 > Michael Van Canneyt via fpc-pascal mailto:fpc-pascal@lists.freepascal.org>>
 > wrote:
 >
 >> On Sat, 12 Feb 2022, Mattias Gaertner via fpc-pascal wrote:
 >>
 >> > Hi,
 >> >
 >> > This can't be right, can it?
 >> >
 >> > type
 >> >  TBird = class
 >> >    procedure Fly;
 >> >  end;
 >> >  TEagle = TBird; // alias
 >> >
 >> > procedure TEagle.Fly;
 >> > begin
 >> > end;
 >>
 >> Personally, I would not allow this.
 >> But Delphi compiles and runs it...
 >
 > ... and Delphi's class completion no longer works in the unit giving a
 > useless error "expected ';' but '.' found". So it is one of those
 > Delphi "features" compiling but not usable.

I'm all for forbidding this in objfpc mode.


Then file a bug report for it. Cause it's definitely going to be one of the low priority things cause it's going to be 
annoying to fix...


I thought (famous last words), checking the typesyms of the tobjectdef would be 
enough but who knows what else will bit :)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-13 Thread Sven Barth via fpc-pascal
Michael Van Canneyt via fpc-pascal 
schrieb am So., 13. Feb. 2022, 09:47:

>
>
> On Sun, 13 Feb 2022, Mattias Gaertner via fpc-pascal wrote:
>
> > On Sat, 12 Feb 2022 12:14:14 +0100 (CET)
> > Michael Van Canneyt via fpc-pascal 
> > wrote:
> >
> >> On Sat, 12 Feb 2022, Mattias Gaertner via fpc-pascal wrote:
> >>
> >> > Hi,
> >> >
> >> > This can't be right, can it?
> >> >
> >> > type
> >> >  TBird = class
> >> >procedure Fly;
> >> >  end;
> >> >  TEagle = TBird; // alias
> >> >
> >> > procedure TEagle.Fly;
> >> > begin
> >> > end;
> >>
> >> Personally, I would not allow this.
> >> But Delphi compiles and runs it...
> >
> > ... and Delphi's class completion no longer works in the unit giving a
> > useless error "expected ';' but '.' found". So it is one of those
> > Delphi "features" compiling but not usable.
>
> I'm all for forbidding this in objfpc mode.
>

Then file a bug report for it. Cause it's definitely going to be one of the
low priority things cause it's going to be annoying to fix...

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-13 Thread Michael Van Canneyt via fpc-pascal



On Sun, 13 Feb 2022, Mattias Gaertner via fpc-pascal wrote:


On Sat, 12 Feb 2022 12:14:14 +0100 (CET)
Michael Van Canneyt via fpc-pascal 
wrote:


On Sat, 12 Feb 2022, Mattias Gaertner via fpc-pascal wrote:

> Hi,
>
> This can't be right, can it?
>
> type
>  TBird = class
>procedure Fly;
>  end;
>  TEagle = TBird; // alias
>
> procedure TEagle.Fly;
> begin
> end; 

Personally, I would not allow this. 
But Delphi compiles and runs it...


... and Delphi's class completion no longer works in the unit giving a
useless error "expected ';' but '.' found". So it is one of those
Delphi "features" compiling but not usable.


I'm all for forbidding this in objfpc mode.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-13 Thread Mattias Gaertner via fpc-pascal
On Sat, 12 Feb 2022 12:14:14 +0100 (CET)
Michael Van Canneyt via fpc-pascal 
wrote:

> On Sat, 12 Feb 2022, Mattias Gaertner via fpc-pascal wrote:
> 
> > Hi,
> >
> > This can't be right, can it?
> >
> > type
> >  TBird = class
> >procedure Fly;
> >  end;
> >  TEagle = TBird; // alias
> >
> > procedure TEagle.Fly;
> > begin
> > end;  
> 
> Personally, I would not allow this. 
> But Delphi compiles and runs it...

... and Delphi's class completion no longer works in the unit giving a
useless error "expected ';' but '.' found". So it is one of those
Delphi "features" compiling but not usable.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-13 Thread Michael Van Canneyt via fpc-pascal



On Sun, 13 Feb 2022, Ryan Joseph via fpc-pascal wrote:





On Feb 12, 2022, at 11:40 PM, Jonas Maebe via fpc-pascal 
 wrote:

I wouldn't consider this to be working by design, but rather because of 
implementation limitations.


I agree and it should be fixed probably.


As I wrote in my initial answer to Mattias, I would also forbid it.
(despite the temptation to use it for shortening class names in the
implementation, I think it will be more confusing than helpful in the end)

But since Delphi allows it, we must continue to allow it in Delphi mode...

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-12 Thread Ryan Joseph via fpc-pascal


> On Feb 12, 2022, at 11:40 PM, Jonas Maebe via fpc-pascal 
>  wrote:
> 
> I wouldn't consider this to be working by design, but rather because of 
> implementation limitations.

I agree and it should be fixed probably.

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-12 Thread Mattias Gaertner via fpc-pascal
On Sat, 12 Feb 2022 17:58:27 +0100
Jonas Maebe via fpc-pascal  wrote:

>[...]
> >> I wouldn't consider this to be working by design, but rather
> >> because of implementation limitations.  

+1
pas2js complained. That's how I found out. Someone renamed a class,
added an alias for compatibility, forgot to rename the
implementation, and fpc did not complain.

 
> > Why do you consider it a limitation ?
> > 
> > Because the compiler currently has no way to distinguish the types
> > when resolving the
> > name "T" (as used in my example)?  
> 
> Indeed.
> 
> > Then it is a strange coincidence that Delphi has it too :-)  
> 
> The simplest way to implement alias types is to just have them refer
> to the original type...

Actually pas2js did an even simpler approach here: Look up the
identifier without resolving the original type ;)

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-12 Thread Jonas Maebe via fpc-pascal

On 12/02/2022 17:47, Michael Van Canneyt via fpc-pascal wrote:

On Sat, 12 Feb 2022, Jonas Maebe via fpc-pascal wrote:


On 12/02/2022 17:36, Michael Van Canneyt via fpc-pascal wrote:
PS. Just tested, the compiler accepts both... Amazing, I never 
thought this

would be possible. I'd better update the docs :-)


I wouldn't consider this to be working by design, but rather because 
of implementation limitations.


Why do you consider it a limitation ?

Because the compiler currently has no way to distinguish the types when 
resolving the

name "T" (as used in my example)?


Indeed.


Then it is a strange coincidence that Delphi has it too :-)


The simplest way to implement alias types is to just have them refer to 
the original type...



Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-12 Thread Michael Van Canneyt via fpc-pascal



On Sat, 12 Feb 2022, Jonas Maebe via fpc-pascal wrote:


On 12/02/2022 17:36, Michael Van Canneyt via fpc-pascal wrote:

PS. Just tested, the compiler accepts both... Amazing, I never thought this
would be possible. I'd better update the docs :-)


I wouldn't consider this to be working by design, but rather because of 
implementation limitations.


Why do you consider it a limitation ?

Because the compiler currently has no way to distinguish the types when 
resolving the
name "T" (as used in my example)?

Then it is a strange coincidence that Delphi has it too :-)

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-12 Thread Jonas Maebe via fpc-pascal

On 12/02/2022 17:36, Michael Van Canneyt via fpc-pascal wrote:

PS. Just tested, the compiler accepts both... Amazing, I never thought this
would be possible. I'd better update the docs :-)


I wouldn't consider this to be working by design, but rather because of 
implementation limitations.



Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-12 Thread Michael Van Canneyt via fpc-pascal



On Sat, 12 Feb 2022, Sven Barth via fpc-pascal wrote:


Michael Van Canneyt via fpc-pascal 
schrieb am Sa., 12. Feb. 2022, 12:14:




On Sat, 12 Feb 2022, Mattias Gaertner via fpc-pascal wrote:


Hi,

This can't be right, can it?

type
 TBird = class
   procedure Fly;
 end;
 TEagle = TBird; // alias

procedure TEagle.Fly;
begin
end;


Personally, I would not allow this.
But Delphi compiles and runs it...

Maybe something to check for {$mode objfpc} =-)



The compiler does not have any real tracking for non-type aliases... As far
as the compiler is concerned these are interchangeable...


I think Mattias just got some more gray hairs :-)

So if I understand this correctly, I can do

---
Interface

Type
  TSomeReallyAnnoyingIncrediblyLongClassName = Class
Procedure DoSomething;
  end;

implementation

Type
  T1 = TSomeReallyAnnoyingUltraLongClassName;

procedure T1.DoSomething;

begin
end;
---

And consequently also

---
Interface

Type
  TSomeReallyAnnoyingIncrediblyLongClassName = Class
  Type
 TSomeReallyAnnoyingSubClass = class
Procedure DoSomething;
 end;
  end;

implementation

Type
  T1 = TSomeReallyAnnoyingIncrediblyLongClassName.TSomeReallyAnnoyingSubClass;

procedure T1.DoSomething;

begin
end;
---

The lazarus code tools maintainer will have a field day with this one ;-)

Michael.

PS. Just tested, the compiler accepts both... Amazing, I never thought this
would be possible. I'd better update the docs :-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-12 Thread Sven Barth via fpc-pascal
Michael Van Canneyt via fpc-pascal 
schrieb am Sa., 12. Feb. 2022, 12:14:

>
>
> On Sat, 12 Feb 2022, Mattias Gaertner via fpc-pascal wrote:
>
> > Hi,
> >
> > This can't be right, can it?
> >
> > type
> >  TBird = class
> >procedure Fly;
> >  end;
> >  TEagle = TBird; // alias
> >
> > procedure TEagle.Fly;
> > begin
> > end;
>
> Personally, I would not allow this.
> But Delphi compiles and runs it...
>
> Maybe something to check for {$mode objfpc} =-)
>

The compiler does not have any real tracking for non-type aliases... As far
as the compiler is concerned these are interchangeable...

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature?

2022-02-12 Thread Michael Van Canneyt via fpc-pascal



On Sat, 12 Feb 2022, Mattias Gaertner via fpc-pascal wrote:


Hi,

This can't be right, can it?

type
 TBird = class
   procedure Fly;
 end;
 TEagle = TBird; // alias

procedure TEagle.Fly;
begin
end;


Personally, I would not allow this. 
But Delphi compiles and runs it...


Maybe something to check for {$mode objfpc} =-)

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] bug or feature?

2022-02-12 Thread Mattias Gaertner via fpc-pascal
Hi,

This can't be right, can it?

type
  TBird = class
procedure Fly;
  end;
  TEagle = TBird; // alias

procedure TEagle.Fly;
begin
end;

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] bug or feature

2021-01-01 Thread Sven Barth via fpc-pascal

Am 01.01.2021 um 19:21 schrieb Mattias Gaertner via fpc-pascal:

Hi,

library test;
procedure Test; begin end;
exports
   Test name 3 'abc';
   //^^^
end.

It's a bug. Please report.

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


Re: [fpc-pascal] bug or feature

2021-01-01 Thread Michael Van Canneyt via fpc-pascal



On Fri, 1 Jan 2021, Mattias Gaertner via fpc-pascal wrote:


Hi,

library test;
procedure Test; begin end;
exports
 Test name 3 'abc';
 //^^^
end.


I think this is a bug. Delphi also barfs on it.


However the following does work:

exports
  Test index 1 name 'abc';

Although incomplete, the following does not mention you can include a number:

http://docwiki.embarcadero.com/RADStudio/Sydney/en/Writing_Dynamically_Loaded_Libraries

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] bug or feature

2021-01-01 Thread Mattias Gaertner via fpc-pascal
Hi,

library test;
procedure Test; begin end;
exports
  Test name 3 'abc';
  //^^^
end.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal