Re: [fpc-pascal] Test Free Pascal program not compiling

2022-09-11 Thread Christo Crause via fpc-pascal
On Mon, 12 Sep 2022, 02:59 Terry A. Haimann via fpc-pascal, <
fpc-pascal@lists.freepascal.org> wrote:

> Trying to compile a small test pascal program on a arm cpu.  I beleive
> it is an a53.  Libre Le Potato
>
> I am getting the following error:
>
> Error: Error while assembling exitcode 1
>
> Thanks in advance,
>
> Terry H.
>

Enable the compiler's verbose mode (-va). The real error is sometimes
printed much earlier in the compiler output.

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


[fpc-pascal] Test Free Pascal program not compiling

2022-09-11 Thread Terry A. Haimann via fpc-pascal
Trying to compile a small test pascal program on a arm cpu.  I beleive
it is an a53.  Libre Le Potato

I am getting the following error:

Error: Error while assembling exitcode 1

Thanks in advance,

Terry H.


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


Re: [fpc-pascal] Get highest element of a StringList

2022-09-11 Thread James Richters via fpc-pascal
The loops is just an example because in my original post of why I wanted to
get the highest element of a stringlist was because I wanted a for loop that
wasn't as clumsy as

For I:=0 to myStringlist.count-1 Do

This came up because thanks to this discussion list, I learned I could use
High() and Low() for my dynamic arrays,  so I went through replacing all
instances of 

Length(MyDynamicArray)-1 with  High(MyDynamicArray)

So my for loops went from:

For I:=0 to Length(MyDynamicArray)-1 Do 
To 
For I:=0 to High(MyDynamicArray) Do

Which I find much more clear and less prone to problems.. I have forgot the
-1 before and it gives range check errors of course.. so I'm switching
everything to use High() instead and will just automatically use High() in
the future, thus preventing the issue all together.

I'm really happy with the helper function and using MyStringList.High.  I
think .High should just be added to all things that have a .Count because
everyone always needs it ALL THE TIME.  But I am happy it's possible to add
a helper function to add it myself.

James

>Why the loop?

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


Re: [fpc-pascal] Why does nested function get corrupted?

2022-09-11 Thread Sven Barth via fpc-pascal
Ondrej Pokorny via fpc-pascal  schrieb am
So., 11. Sep. 2022, 15:29:

> Am 11.09.2022 um 14:22 schrieb Sven Barth via fpc-pascal:
>
> Ondrej Pokorny via fpc-pascal  schrieb
> am So., 11. Sep. 2022, 12:18:
>
>> Shouldn't this assignment be forbidden?
>>
>> type
>>   TProc = procedure is nested;
>> function TestNested: TProc;
>> begin
>>   result := procedure // why is this possible?
>>   begin
>> writeln(data);
>>   end;
>>
>> It is not a nested function but an anonymous one.
>>
>>
> And? An anonymous function is assignment compatible to multiple left sides
> depending on what it captures. See my announcement mail.
>
> Thank you Sven - I missed this info in your email.
>
It's an extension I had done compared to Delphi so that anonymous functions
are also usable without function references which are a bit more heavy
weight after all.

Regards,
Sven

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


Re: [fpc-pascal] Why does nested function get corrupted?

2022-09-11 Thread Ondrej Pokorny via fpc-pascal

Am 11.09.2022 um 14:22 schrieb Sven Barth via fpc-pascal:
Ondrej Pokorny via fpc-pascal  
schrieb am So., 11. Sep. 2022, 12:18:


Shouldn't this assignment be forbidden?

type
   TProc = procedure is nested;
function TestNested: TProc;
begin
   result := procedure // why is this possible?
   begin
 writeln(data);
   end;

It is not a nested function but an anonymous one.


And? An anonymous function is assignment compatible to multiple left 
sides depending on what it captures. See my announcement mail.


Thank you Sven - I missed this info in your email.

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


Re: [fpc-pascal] Why does nested function get corrupted?

2022-09-11 Thread Sven Barth via fpc-pascal
Ondrej Pokorny via fpc-pascal  schrieb am
So., 11. Sep. 2022, 12:18:

> Am 11.09.2022 um 11:26 schrieb Sven Barth via fpc-pascal:
>
> Hairy Pixels  schrieb am Sa., 10. Sep. 2022, 03:21:
>
>>
>>
>> > On Sep 9, 2022, at 4:48 PM, Sven Barth 
>> wrote:
>> >
>> > How about you simply report such corruptions as bugs? I can always
>> close them as "not a bug" or duplicate if necessary.
>> >
>>
>> Well I thought the data may have been saved on the stack and thus lost
>> when the function exits. What is the expected behavior for passing these
>> outside of the calling scope?
>>
>
> Looking at your example again - I'm only on my phone currently - it's
> indeed your fault because the state passed to a nested function variable
> does *not* survive the stack frame it belongs to. That's where function
> references shine, because there the state *does* survive.
>
> Shouldn't this assignment be forbidden?
>
> type
>   TProc = procedure is nested;
> function TestNested: TProc;
> begin
>   result := procedure // why is this possible?
>   begin
> writeln(data);
>   end;
>
> It is not a nested function but an anonymous one.
>
>
And? An anonymous function is assignment compatible to multiple left sides
depending on what it captures. See my announcement mail.

Regards,
Sven

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


Re: [fpc-pascal] Why does nested function get corrupted?

2022-09-11 Thread Ondrej Pokorny via fpc-pascal

Am 11.09.2022 um 11:26 schrieb Sven Barth via fpc-pascal:

Hairy Pixels  schrieb am Sa., 10. Sep. 2022, 03:21:



> On Sep 9, 2022, at 4:48 PM, Sven Barth
 wrote:
>
> How about you simply report such corruptions as bugs? I can
always close them as "not a bug" or duplicate if necessary.
>

Well I thought the data may have been saved on the stack and thus
lost when the function exits. What is the expected behavior for
passing these outside of the calling scope?


Looking at your example again - I'm only on my phone currently - it's 
indeed your fault because the state passed to a nested function 
variable does *not* survive the stack frame it belongs to. That's 
where function references shine, because there the state *does* survive.


Shouldn't this assignment be forbidden?

type
  TProc = procedure is nested;
function TestNested: TProc;
begin
  result := procedure // why is this possible?
  begin
writeln(data);
  end;

It is not a nested function but an anonymous one.

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


Re: [fpc-pascal] Get highest element of a StringList

2022-09-11 Thread Sven Barth via fpc-pascal
James Richters via fpc-pascal  schrieb am
Sa., 10. Sep. 2022, 22:55:

>
> For some reason
> {$Mode FPC}
> {$modeswitch typehelpers}
> Still had Error: Identifier not found "class"
>

Because support for the "class" keyword is only available when the
modeswitch Class is enabled which is the case for the ObjFPC and Delphi
modes.
You don't need the TypeHelpers mode switch for "class helper", only for
"type helper".

Regards,
Sven

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


Re: [fpc-pascal] Why does nested function get corrupted?

2022-09-11 Thread Sven Barth via fpc-pascal
Hairy Pixels  schrieb am Sa., 10. Sep. 2022, 03:21:

>
>
> > On Sep 9, 2022, at 4:48 PM, Sven Barth 
> wrote:
> >
> > How about you simply report such corruptions as bugs? I can always close
> them as "not a bug" or duplicate if necessary.
> >
>
> Well I thought the data may have been saved on the stack and thus lost
> when the function exits. What is the expected behavior for passing these
> outside of the calling scope?
>

Looking at your example again - I'm only on my phone currently - it's
indeed your fault because the state passed to a nested function variable
does *not* survive the stack frame it belongs to. That's where function
references shine, because there the state *does* survive.

Regards,
Sven

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


Re: [fpc-pascal] Internal error 2019022201 from function reference

2022-09-11 Thread Sven Barth via fpc-pascal
Hairy Pixels via fpc-pascal  schrieb am
Fr., 9. Sep. 2022, 18:05:

> This program gives internal compiler error 2019022201 (Free Pascal
> Compiler version 3.3.1 [2022/05/27] for aarch64). Something is wrong with
> the PPU. This is a very basic program using function references so  it
> seems unlikely it could not be known. Any ideas?
>

Why do you think it's not known if there is an internal error? Internal
errors are precisely there to cover cases that should not be taken, but are
then triggered by some code path that was not thought about.
As a general rule: always report an internal error if it wasn't reported
already. If it was then check whether you can  maybe provide a better
example to reproduce it.

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


Re: [fpc-pascal] Getting Shift key with PTCCRT

2022-09-11 Thread wkitty42--- via fpc-pascal

On 9/10/22 10:57 AM, James Richters wrote:

Thanks for the suggestion

I think the syntax should be:
type myKeyEvent = IPTCKeyEvent;
Var myShiftStatus : boolean;

myShiftStatus := myKeyEvent.Shift;


i told you i probably had the syntax wrong :lol:


but I get IPTCKeyEvent not found.  I wonder if it's only designated as
internal.. or if I need to use something other than PTCGraph and PTCCRT


you're probably not using the ptc unit directly so you can use it in your 
code...

i don't like this documentation format without examples but it is what it is...

  https://ptcpas.sourceforge.io/api-reference/ptc/index-4.html

also look here in procedure GetKeyEvents...


https://github.com/alrieckert/freepascal/blob/master/packages/graph/src/ptcgraph/ptccrt.pp

if you are already using PTC's keyevents, then you should be able to get the 
shift status already...




i'm not even going to try writing any code this time... i don't have FPC or even 
TP/BP installed any more since i stopped writing code for fidonet stuff some 
years back ;)



--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list where it belongs!*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Get TMethod from function reference

2022-09-11 Thread Ondrej Pokorny via fpc-pascal

Am 09.09.2022 um 00:49 schrieb Hairy Pixels via fpc-pascal:

On Sep 8, 2022, at 11:14 AM, Michael Van Canneyt via fpc-pascal 
 wrote:

It must keep this information somewhere, but this does not mean you can 
typecast it to a TMethod.

Indeed. I wonder if this information could be exposed by some method in the 
interface? It would be useful to introspect the target class like you can do 
with “of object”.


See the announcement email from Sven to the fpc-pascal mailing list: 
https://lists.freepascal.org/pipermail/fpc-pascal/2022-May/060507.html


They [function references] get their great power from a point that is 
for once *not*

considered an implementation detail: function references are in fact
internally declared as reference counted interfaces with a single
Invoke() method of the provided signature. So the above examples are in
fact declared like this:

=== code begin ===

type
   TProcLongInt = interface(IInterface)
 procedure Invoke(aArg: LongInt); stdcall; overload;
   end;

You should be able to get the Invoke procedure pointer from the RTTI.

Ondrej

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