Re: [fpc-pascal] Generic compiler error

2017-10-22 Thread Marco van de Voort
In our previous episode, Sven Barth via fpc-pascal said:
> 
> Type aliases are currently not supported in mode Delphi. In mode ObjFPC
> they might work, but I'm not sure about that either...
> 
> That said I also don't see the use of type aliases for generics...

How about a simple


type   = anotherunit.; 

?

That is often what I use type aliases for, aliasing code that has been
factored out of an unit back in.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Generic compiler error

2017-10-22 Thread Sven Barth via fpc-pascal
Am 23.10.2017 04:14 schrieb "Marcos Douglas B. Santos" :

Hi,

In Pascal we can do this:

type
  TXStream = TStream;

Now, TXStream is just an alias to TStream.

How do the same with generic classes, using mode delphi?

  TBar = TFoo;



Type aliases are currently not supported in mode Delphi. In mode ObjFPC
they might work, but I'm not sure about that either...

That said I also don't see the use of type aliases for generics...

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

Re: [fpc-pascal] Generic compiler error

2017-10-22 Thread Ryan Joseph


> On Oct 23, 2017, at 9:14 AM, Marcos Douglas B. Santos  
> wrote:
> 
> How do the same with generic classes, using mode delphi?

I think you need to specialize then alias the specialize type. Why do you want 
to make an alias for an untyped generic anyways?


Regards,
Ryan Joseph

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

[fpc-pascal] Generic compiler error

2017-10-22 Thread Marcos Douglas B. Santos
Hi,

In Pascal we can do this:

type
  TXStream = TStream;

Now, TXStream is just an alias to TStream.

How do the same with generic classes, using mode delphi?

  TBar = TFoo;

Compile Project, Target: C:\temp\project1.exe: Exit code 1, Errors: 4
project1.lpr(25,18) Error: Identifier not found "T"
project1.lpr(25,19) Error: Type identifier expected
project1.lpr(25,20) Error: Error in type definition
project1.lpr(27,1) Error: This type cannot be a generic

My ENV is:
Lazarus 1.9.0 r56056M
FPC 3.1.1 r37505
i386-win32-win32/win64


Please, see an example below:

=== BEGIN ===

program Project1;

{$mode delphi}

uses
  Classes;

type
  IFoo = interface
  ['{5CA4AEC4-3875-4639-9975-AC2C201E0A98}']
function Value: T;
  end;

  TFoo = class(TInterfacedObject, IFoo)
  private
FValue: T;
  public
constructor Create(Value: T);
class function New(Value: T): IFoo;
function Value: T;
  end;

  TXStream = TStream;  //  OK

  TBar = TFoo; //  how solve this?

constructor TFoo.Create(Value: T);
begin
  inherited Create;
  FValue := Value;
end;

class function TFoo.New(Value: T): IFoo;
begin
  Result := Create(Value);
end;

function TFoo.Value: T;
begin
  Result := FValue;
end;

begin
  Writeln(TFoo.New(1).Value);
  Readln;
end.

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

Re: [fpc-pascal] Plans to support various ISO modes

2017-10-22 Thread Marco van de Voort
In our previous episode, Sven Barth via fpc-pascal said:

FPC ISO modes are primarily geared to recompiling complaint code, not to
reject standards corner cases. 

> 5. Doesn't implement conformant arrays
> 
> It might be that these are supported in trunk as well, but I'm not sure.

(Afaik conformant arrays are an optional part of standard pascal) 

> Trunk supports Standard Pascal good enough that the P5 code can be compiled
> without changes. And yes, the end goal is to have full support for both
> standards (especially for ExtPas, which is still in its infancy, patches
> are welcome).

Another problem that I can remember with iso mode is that there was some
problem with passing fields that are in a variant records node to VAR
parameters and while probably nonstandard, some versions of P4 relied on
taking the ORD() of a pointer for pointermath.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Plans to support various ISO modes

2017-10-22 Thread Sven Barth via fpc-pascal
Am 22.10.2017 10:51 schrieb "Dominik Rappaport" :

Hi,

I hope this question is not part of the FAQ list. What are the plans for
FPC as to the support of the various ISO modes of Pascal? At the moment,
there is a switch to enable "ISO" mode, but it's unclear to me which ISO
standard this option enforces (Standard Pascal 1983 or 1990 or Extended
Pascal). In particular, because even some features from Standard Pascal are
missing:


 The ISO mode refers to Standard Pascal. In trunk there's also a new
work-in-progress ExtPas mode.

For example, FPC:

1. Doesn't raise an error or warning if the wrong order of statements (var
before type) is specified, as mandated by Standard Pascal
2. Doesn't raise an error or warning if "(input, output)" or an equivalent
statement is missing after "program", as mandated by Standard Pascal


Patches welcome.

3. Doesn't implement the get and put procedure
4. Doesn't support Standard Pascal I/O (like f^ as the current input/output)


AFAIK these should be implemented in trunk.

5. Doesn't implement conformant arrays


It might be that these are supported in trunk as well, but I'm not sure.


I've found an old statement where you referred everybody looking for strict
ISO compliance to GNU Pascal. However, GNU Pascal has been discontinued, so
the question arises, whether FPC is going to support a "strict
Standard/Extended Pascal mode" (ideally both) with a full support of these
standards.


Trunk supports Standard Pascal good enough that the P5 code can be compiled
without changes. And yes, the end goal is to have full support for both
standards (especially for ExtPas, which is still in its infancy, patches
are welcome).

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

[fpc-pascal] Plans to support various ISO modes

2017-10-22 Thread Dominik Rappaport
Hi,

I hope this question is not part of the FAQ list. What are the plans for FPC as 
to the support of the various ISO modes of Pascal? At the moment, there is a 
switch to enable "ISO" mode, but it's unclear to me which ISO standard this 
option enforces (Standard Pascal 1983 or 1990 or Extended Pascal). In 
particular, because even some features from Standard Pascal are missing:

For example, FPC:

1. Doesn't raise an error or warning if the wrong order of statements (var 
before type) is specified, as mandated by Standard Pascal
2. Doesn't raise an error or warning if "(input, output)" or an equivalent 
statement is missing after "program", as mandated by Standard Pascal
3. Doesn't implement the get and put procedure
4. Doesn't support Standard Pascal I/O (like f^ as the current input/output)
5. Doesn't implement conformant arrays

I've found an old statement where you referred everybody looking for strict ISO 
compliance to GNU Pascal. However, GNU Pascal has been discontinued, so the 
question arises, whether FPC is going to support a "strict Standard/Extended 
Pascal mode" (ideally both) with a full support of these standards.

Best regards,
Dominik
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal