Re: [fpc-pascal] Subscript pointers

2023-06-26 Thread Steve Litt via fpc-pascal
Hairy Pixels via fpc-pascal said on Mon, 26 Jun 2023 18:52:16 +0700 >> On Jun 26, 2023, at 3:48 PM, Steve Litt via fpc-pascal >> wrote: >> >> Why do you need pointers at all? Pointers aren't *usually* an asset. >> > >Seriously? anytime you allocate something on the heap you need a >pointer.

Re: [fpc-pascal] Subscript pointers

2023-06-26 Thread Hairy Pixels via fpc-pascal
> On Jun 26, 2023, at 3:48 PM, Steve Litt via fpc-pascal > wrote: > > Why do you need pointers at all? Pointers aren't *usually* an asset. Seriously? anytime you allocate something on the heap you need a pointer. Classes are pointers even. Regards, Ryan Joseph

Re: [fpc-pascal] Subscript pointers

2023-06-26 Thread Steve Litt via fpc-pascal
Hairy Pixels via fpc-pascal said on Sun, 25 Jun 2023 11:20:53 +0700 >> On Jun 24, 2023, at 8:00 PM, Steve Litt via fpc-pascal >> wrote: >> >> I don't do much with Pascal pointers, but it looks to me like you: >> >> * Set p to the address of i >> * Set the contents of p to 100 >> * Read the cont

Re: [fpc-pascal] Subscript pointers

2023-06-24 Thread Hairy Pixels via fpc-pascal
> On Jun 24, 2023, at 8:00 PM, Steve Litt via fpc-pascal > wrote: > > I don't do much with Pascal pointers, but it looks to me like you: > > * Set p to the address of i > * Set the contents of p to 100 > * Read the contents of p, which of course would be the value of i, 100 > * Read the cont

Re: [fpc-pascal] Subscript pointers

2023-06-24 Thread Steve Litt via fpc-pascal
Hairy Pixels via fpc-pascal said on Thu, 22 Jun 2023 20:23:13 +0700 >I've forgotten entirely, what does subscripting a pointer do in >Pascal? p[0] returns 100 but after that garbage. Seems like a c-style >array which doesn't feel right in the language. > >var > i: Integer; > p: PInteger; >begin

Re: [fpc-pascal] Subscript pointers

2023-06-22 Thread Michael Van Canneyt via fpc-pascal
On Thu, 22 Jun 2023, Hairy Pixels via fpc-pascal wrote: On Jun 22, 2023, at 8:41 PM, Michael Van Canneyt via fpc-pascal wrote: It's for easier pointer math, a construct which has been used in FPC since day 1 (AFAIK). Use with care, since no boundary checks are done. You mean instead

Re: [fpc-pascal] Subscript pointers

2023-06-22 Thread Hairy Pixels via fpc-pascal
> On Jun 22, 2023, at 8:41 PM, Michael Van Canneyt via fpc-pascal > wrote: > > It's for easier pointer math, a construct which has been used in FPC since > day 1 (AFAIK). > Use with care, since no boundary checks are done. You mean instead of doing p + 1 or you can do p[1]? It may have been

Re: [fpc-pascal] Subscript pointers

2023-06-22 Thread Michael Van Canneyt via fpc-pascal
On Thu, 22 Jun 2023, Hairy Pixels via fpc-pascal wrote: I've forgotten entirely, what does subscripting a pointer do in Pascal? p[0] returns 100 but after that garbage. Seems like a c-style array which doesn't feel right in the language. var i: Integer; p: PInteger; begin p := @i