pointerful

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

pointerful

Mattias Gaertner
Hi,

Is this a bug or a feature:

type
  Pint = ^int;
  int = PInt;

?

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pointerful

Mattias Gaertner
On Sun, 22 Apr 2018 17:00:35 +0200
Mattias Gaertner <[hidden email]> wrote:

> Hi,
>
> Is this a bug or a feature:
>
> type
>   Pint = ^int;
>   int = PInt;
>
> ?

Note that Delphi gives error "Type 'PInt' is not yet completely
defined".

Mattias
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pointerful

Jonas Maebe-3
In reply to this post by Mattias Gaertner
On 22/04/18 17:00, Mattias Gaertner wrote:

> Is this a bug or a feature:
>
> type
>    Pint = ^int;
>    int = PInt;
>
> ?

It's a bug.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pointerful

Alexander Grotewohl
imagine a linked list.. with nothing but the pointers.. lol


On 4/22/2018 1:05 PM, Jonas Maebe wrote:

> On 22/04/18 17:00, Mattias Gaertner wrote:
>
>> Is this a bug or a feature:
>>
>> type
>>    Pint = ^int;
>>    int = PInt;
>>
>> ?
>
> It's a bug.
>
>
> Jonas
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pointerful

Bernd Oppolzer
program TESTPT ( OUTPUT ) ;

//************************************************
//$A+ ... enable Assembler output
//************************************************

type PT = -> PT ;

var PTEST : PT ;

function LQUEUE ( P : PT ) : INTEGER ;

    var L : INTEGER ;

    begin (* LQUEUE *)
      L := 0 ;
      while P <> NIL do
        begin
          P := P -> ;
          L := L + 1
        end (* while *) ;
      LQUEUE := L
    end (* LQUEUE *) ;

begin (* HAUPTPROGRAMM *)
   NEW ( PTEST ) ;
   NEW ( PTEST -> ) ;
   NEW ( PTEST -> -> ) ;
   NEW ( PTEST -> -> -> ) ;
   NEW ( PTEST -> -> -> -> ) ;
   NEW ( PTEST -> -> -> -> -> ) ;
   PTEST -> -> -> -> -> := NIL ;
   WRITELN ( LQUEUE ( PTEST ) ) ;
end (* HAUPTPROGRAMM *) .


the result is:

c:\work\pascal\work>pcint prr=testpt.prr inc=paslibx,pasutils,
pas=testpt.pas out=testpt.prrlis

PCINT (Build 1.0 Apr  5 2018 07:58:58)

            5

c:\work\pascal\work>


this is the New Stanford Pascal compiler,
a modern variant of Wirth's P4 compiler.

that is:

type
      PINT = -> INT ;
      INT = PINT ;
      PT = -> PT ;

this is all possible in Standard Pascal, IMO,
although not very useful, of course.

Kind regards

Bernd



Am 22.04.2018 um 23:30 schrieb Alexander Grotewohl:

> imagine a linked list.. with nothing but the pointers.. lol
>
>
> On 4/22/2018 1:05 PM, Jonas Maebe wrote:
>> On 22/04/18 17:00, Mattias Gaertner wrote:
>>
>>> Is this a bug or a feature:
>>>
>>> type
>>>    Pint = ^int;
>>>    int = PInt;
>>>
>>> ?
>>
>> It's a bug.
>>
>>
>> Jonas
>> _______________________________________________
>> fpc-pascal maillist  -  [hidden email]
>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal