Re: [fpc-pascal] Function reference confuses function pointer?

2023-03-03 Thread Dwight Schauer via fpc-pascal

On 3/3/23 22:08, Hairy Pixels via fpc-pascal wrote:

This caused me a nasty debugging confusion, it’s a bug right? In the program 
below the two parameters passed to TBinding.Create have the same address 
despite being function pointers to two different class methods. Calling them 
both call the same method which is clearly not correct.

Free Pascal Compiler version 3.3.1 [2022/09/28] for aarch64


I modified the methods in question from your example and called them. 
They were separate.


This was already addressed.

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

resolved in commit a714e2ff 3 months ago



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


Re: [fpc-pascal] Function reference confuses function pointer?

2023-03-03 Thread Dwight Schauer via fpc-pascal

On 3/3/23 22:08, Hairy Pixels via fpc-pascal wrote:

This caused me a nasty debugging confusion, it’s a bug right? In the program 
below the two parameters passed to TBinding.Create have the same address 
despite being function pointers to two different class methods. Calling them 
both call the same method which is clearly not correct.

Free Pascal Compiler version 3.3.1 [2022/09/28] for aarch64

2022/09/28?

Does not do this 3.3.1 [2023/03/02] for me. I get different addresses.

$ fpc same.pas
Free Pascal Compiler version 3.3.1 [2023/03/02] for x86_64
Copyright (c) 1993-2023 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling same.pas
same.pas(37,19) Warning: Function result does not seem to be set
Linking same
52 lines compiled, 0.2 sec, 144256 bytes code, 57848 bytes data
1 warning(s) issued

$ ./same
7FA3B433A080
7FA3B433A078


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


Re: [fpc-pascal] Duplicate identifier "$result"

2023-02-24 Thread Dwight Schauer via fpc-pascal


On 2/24/23 22:37, Hairy Pixels via fpc-pascal wrote:
I’m trying to build a project on Windows and I’m getting the error 
mentioned in the subject. It appears to be from a nested function in a 
generic class which is using the “result” keyword to assign the value. 
Is this a bug or do I need to enable some extra compiler flag on Windows?


It is a bug. (as far as I can tell)

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


Here’s the compiler I’m using. Free Pascal Compiler version 3.3.1 
[2023/02/24] for i386 

From that report:

Operating system: Linux, AlmaLinux 9.1, X86_64
Processor architecture: X86_64, 64 bit
Compiler version: 3.3.1-12327-gb997e413
Device: Computer
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Programming Pascal using an AI Chatbot

2023-01-03 Thread Dwight Schauer via fpc-pascal


On 1/3/23 11:17, Anthony Walter via fpc-pascal wrote:


In summary, while OpenGPT is obviously imperfect, generally it feels 
like a revolutionary leap forward of several magnitudes. It ought to 
be plainly clear that the proverbial toothpaste is now out of the tube 
and there is no going back. These types of artificial 
intelligence (AI) are only going to become more refined, accurate, and 
prevalent. The idea many scholars or businesses have expressed to 
somehow restrain them is beyond myopic. Instead, everyone should 
familiarize themselves with this new category of AIs right now, their 
limitations (as you have expressed), their benefits, and most 
importantly how they can be molded in further revisions to be better 
rather than relegated.




Agreed. I see OpenAI ChatGPT a tip of the iceberg sampling of what is to 
come.


In the way it is currently, though rather crippled in many areas, it is 
still revolutionary and extremely useful.


But one must understand it's limitations.

It guesses a lot and that is usually good, but it still often gets 
things wrong.



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


Re: [fpc-pascal] Programming Pascal using an AI Chatbot

2023-01-03 Thread Dwight Schauer via fpc-pascal
Pascal is still limited with OpenAI ChatGPT unless you stick to very 
core things in Pascal, and are patient to teach it about non-core things.


Limited compared Python and other languages. Asking it to do specific 
things Python using standard modules give better results C++ with 
something like Qt6.



Free Pascal is even more limited than C++ as far as what OpenAI ChatGPT 
can provide.


OpenAI ChatGPT is still very useful for Free Pascal though.


On 1/2/23 15:05, Dwight Schauer wrote:
I started a new chat and conducted a mock interview of it for a 
hypothetical programmer position.


I had to give it the same benefit of the doubt I would give to humans 
on some answers as far as follow up questions to get the answer I was 
looking for.


In just about every area it gave more comprehensive answers than any 
human could.


And gave satisfactory correct answers in every other area.

Discussed a variety of issues, low/medium/high level stuff, 
theoretical, hypothetical, troubleshooting, pros/cons of one approach 
over another, workplace scenarios, email/IT scams, etc...


It matched or out performed a human on just about everything.

Well, except for "what are your hobbies..." But it was able to 
comprehensively answer all non computer related hobby question I threw 
at it.


But it an illusion. While it may "sound impressive" if you try to test 
if it has deep cognitive abilities knowing it was a limited AI, it would 
fail, and fail miserably.


But in an interview with a person, if they answered all those questions 
in the way that way, you would not really think to test their cognitive 
abilities to that extreme.



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


Re: [fpc-pascal] Programming Pascal using an AI Chatbot

2023-01-02 Thread Dwight Schauer via fpc-pascal

I've been played with OpenAI ChatGPT some.

I had it write a few Pascal programs and refactor them into multiple 
units per my specifications.


I did the same with other programming languages, then asked It to 
rewrite what I'd done with those in Pascal or one of the others.



Including doing them same things in assembly code for x86_64 Linux.

It tried to send two strings arguments using the Linux write syscall, 
the second argument being specified in a string template of the first 
argument.


I had to explain it could not do that, so it dropped the %s from the 
first string and did a second write for the second string argument.



Not perfect results each time, but I quickly was able to able to close 
the loop with it to correct things and produce code that ran.



On one C++ example I got a linker error, and it gave me the correct 
command line option much faster than a google search and digging through 
the results would have taken me.


I was able to tell it to write some a simple GUI program in C++ using 
qt6. Graph two cycles of a sine wave, move a rotating circle back and 
force along the course of the sine wave.


It took several iterations of me correcting it with suggestions and 
hints, and it finally got it working.



I played stupid on a lot of things, telling it what distro I was on, 
what commands needed to install certain things. It have me detailed 
steps on everything.


I asked about one C library, dwindows, and it knew nothing about it.

I gave the chat bot the website for dwindows and it was then able to 
answer questions about it.


I asked it for some sample code on such and such using it, and it gave 
it too. I asked for specific modifications that would not have been in 
an example for dwindows, and it was able to make the changes, which at 
some level shows it was parsing the documentation for the API.



I started a new chat and conducted a mock interview of it for a 
hypothetical programmer position.


I had to give it the same benefit of the doubt I would give to humans on 
some answers as far as follow up questions to get the answer I was 
looking for.


In just about every area it gave more comprehensive answers than any 
human could.


And gave satisfactory correct answers in every other area.

Discussed a variety of issues, low/medium/high level stuff, theoretical, 
hypothetical, troubleshooting, pros/cons of one approach over another, 
workplace scenarios, email/IT scams, etc...


It matched or out performed a human on just about everything.

Well, except for "what are your hobbies..." But it was able to 
comprehensively answer all non computer related hobby question I threw 
at it.



But back to Pascal, first results did not always work, I'd need to 
suggest alternatives. Most of the time existing units sufficed, but in 
other places I'd tell it to resort to libc calls, or inline assembly, 
and it would eventually produce working code. With a bit more coercing I 
could have likely gotten existing units to work in those scenarios.


Main problem I ran into is things need to be small. If the code in 
question was too big, it would break it up and I'd need to ask for 
continue, and it did not always splice the continuations correctly.


The incorrect answers did not bother me, as I was for the most part able 
to work with it to correct things.


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


Re: [fpc-pascal] Working on a new way to educate people about pascal

2022-12-29 Thread Dwight Schauer via fpc-pascal


On 12/29/22 09:53, Adriaan van Os via fpc-pascal wrote:
Modern mathematics education tries to teach by showing graphs and 
pictures, instead of formulas and proofs. But, by doing so, it misses 
the most important point — that mathematics is about abstract 
thinking. You will never get around the point that it is the abstract 
thinking that must be taught.



The latter (formulas and proofs in mathematics) is what gave me a head 
start in programming in high school before I had an formal computer 
science classes (programming or otherwise).


After just a few hours playing with Basic I was like hmm... I already 
was taught most of this stuff, this is a way to apply it...



I had liked doing all the proofs in High School geometry. I just had not 
seen a practical value in them. When I was learning to program I was 
like wow, this is what all the stuff was for.


So most of my first self taught stuff was related to geometry, but 
primarily algebra and trigonometry.



But the latter two did not lay the computer programming foundation for 
me like geometry did.



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


Re: [fpc-pascal] Working on a new way to educate people about pascal

2022-12-29 Thread Dwight Schauer via fpc-pascal


On 12/28/22 06:01, Hairy Pixels via fpc-pascal wrote:



On Dec 28, 2022, at 4:45 PM, wkitty42--- via fpc-pascal 
 wrote:

like james, i also have like 40-45 years programming experience... 99% of my 
stuff is still text mode tools and apps... GUI stuff has just never made sense 
to me...

Just curious, how so? GUI is usually the easiest parts of programming but these 
days using Pascal there aren’t many options. Should be easy to pick up some 
tutorials even if it’s another language with a good framework for what ever 
platform you use.


If you have a top-down view then GUIs have the illusion of being easy, 
because you are blissfully ignorant of their complexity.


With that blissful ignorance one is forced to master event based 
programming model, which among other things in GUI programming is a 
fairly advanced topic.



If you have a bottom-up view, then you understand that GUIs are 
extremely complex. They are anything but "simple".


If you understand interrupts and real time embedded systems, then you 
will grasp event-based base programming with a far deeper understand 
then the beginner programmer.



I've done a lot of GUI work in the distant past and web-ui work in the 
not so distant past, but before that learned bottom up.


Web-UI's are far from being simple, they are even more complex than a 
native GUI app, and are an even higher layer on top of even more complex 
software.


To write good Web-UIs, once again, among other things, event-based 
programming...



So starting out with GUIs and Web-UIs beginners is forcing them deal 
with very advanced concepts right away. Yes, there is the visual appeal, 
but it is an illusion in my opinion. Like wkitty42, I've been 
programming for a while, only 30 to 35 years though, since the mid 80s, 
more so since the early 90s.



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


Re: [fpc-pascal] FPC coding standards

2020-08-18 Thread Dwight Schauer via fpc-pascal
On Wed, 2020-08-19 at 02:03 +0200, Michael Van Canneyt wrote:
> 
> On Tue, 18 Aug 2020, Dwight Schauer via fpc-pascal wrote:
> As long as the code only gets alterned into something logically
> > equivalaent, and as long as I can retreive the contents of comments
> > formatted as they were originally, I'm not concerned. (Other than
> > enforcing so many so many spaces after something like // and before
> > it,
> > lining up // on adjacent lines in a configurable manner, etc.)
> 
> You cannot easily do this with the current fcl-passrc. In fact, I
> would
> not recommend it.
> 
> The comments are not kept and do not appear in the AST built by the
> parser.
> There is a way to keep the comments, but all info as to where they
> should be
> inserted is lost. There are ways to solve this, but you will never be
> able
> to insert all comments again; only some constructs can be recognized
> and
> reproduced.
> 
> A second problem is that if you use IFDEFS, you will only see the
> part of
> your code that corresponds to the conditional branches taken in the
> code.
> 
> If you are concerned with reformatting only, then ptop is the better
> way to go.
> It just cares about tokens, and will process all branches of
> conditional
> code.

Thank you! This is why I asked on on this email list.
ptop it will need to be then...

I'm not sure if I can get function/procedure modifiers to work without
source code changes (to ptop), but I'll find out...
It seems like most everything else works with config tweaks, but I'll
need to verify that.

Once again, thanks.

Sincerely,
Dwight Schauer


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


Re: [fpc-pascal] FPC coding standards

2020-08-18 Thread Dwight Schauer via fpc-pascal
On Tue, 2020-08-18 at 23:17 +0200, Marco van de Voort via fpc-pascal
wrote:
> Op 2020-08-18 om 23:01 schreef Sven Barth via fpc-pascal:
> > Might be the even better solution as fcl-passrc will be better 
> > maintained due to it being used for both the documentation utility 
> > fpdoc as well as pas2js.
> > 
> Parsers for compilers or source transformation usually discard 
> whitespace asap, while editor and formatting parsers don't. Usually
> they 
> are different beasts.

The only signifiicant whitespace I'm concerned about is that found in
string literals and in comments. Other whitespace or manual formatting
does not really apply to any strict standard style conformance. I'm not
looking for something that honors personal tweaking here and there.

As far as whitespace in literal strings, I'm sure those don't get
mangled for pas2js (other than maybe the escaped characters changing,
but the transformed string is still going to be an equivalent one).

Now I've seen formatters for other languages, Go for instance, that
sort imports and removes ones that are not referenced.

I'm not looking to set up something that invasive. I just want
something that I have a few sets of configs that I'm able to tweak
make the code adhere to different standards or formatting style. And
have one for the style I prefer, but if I need something to be in
someone else's style, no problem. (Which I can currently do with clang-
tidy).

clang-tidy in my experience for C/C++ seems to throw away all your
whitespace, and reformat according the standard you have chose (which
you can tweak). With some exception though as far "all whitespace".

As long as the code only gets alterned into something logically
equivalaent, and as long as I can retreive the contents of comments
formatted as they were originally, I'm not concerned. (Other than
enforcing so many so many spaces after something like // and before it,
lining up // on adjacent lines in a configurable manner, etc.)

Sincerely,
Dwight


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


Re: [fpc-pascal] FPC coding standards

2020-08-18 Thread Dwight Schauer via fpc-pascal
On Tue, 2020-08-18 at 14:11 +0200, Sven Barth wrote:
> Not that I know. Most formatters will barf on some of the syntax
> extensions that FPC provides (see the Jedi Code Formatter that barfs
> on generic syntax). Even ptop might fail on newer language
> extensions... 
> 
> So improving ptop might indeed be the way to go if you want that. 

Thanks.

I see what I can do with ptop config and if need be see what it will
take to improve ptop. Or investigate starting over with pparser,
pastree, paswrite, as I'm already looking at those for some other
things.
https://wiki.lazarus.freepascal.org/fcl-passrc

Sincerely,
Dwight Schauer



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


Re: [fpc-pascal] FPC coding standards

2020-08-18 Thread Dwight Schauer via fpc-pascal
On Tue, 2020-08-18 at 11:08 +0200, Sven Barth via fpc-pascal wrote:
> ...
> There is no default configuration, because there is not one default
> standard. ...

Understood.

> Rule of thumb is that contributions should fit into the existing
> style. 

In general when it comes to programming it is better to let
programmers focus on content, not style (especially when there is
supposed to only be one style in a given source file).

One could argue that lack of standardization (and tools to enforce thos
standards) cause programmers to do menial tasks that computers can do
much better at

I guess I will need to make my own configs for ptop if I don't want to
be forced to manually focus on style...

It seems ptop does not understand function/procedure modifiers.
 https://www.freepascal.org/docs-html/ref/refsu3.html 

Maybe it does support/understand those, I'll just need to dig through
the configs, as theire is mention of "modifier" or "modifiers" in the
default config output. Of hand I don't see a "nocrbefore", but I see
functions have a type as the last item, but no modifiers...

The default config for ptop does not understand asm, but there is blank
entry for it, and I see that giving it the same rules as begin works
fine.

Is there a more robust code reformatter (command line / batch oriented)
that can used with free pascal? (before I start digging in to making
ptop work to remove one's focus from style and put it solely on
content?)


Sincerely,
Dwight Schauer


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


[fpc-pascal] FPC coding standards

2020-08-18 Thread Dwight Schauer via fpc-pascal

Hello FPC Pascal users,

Is there a default ptop.cfg somewhere that follows the FPC coding standards?

https://wiki.freepascal.org/Coding_style

I'm not looking to submit any PR in the near future, I just want to
be able to automatically reformat my code to conform to what I consider
a reasonable standard, rather than having to enforce that manually.

Or config for any other invoked from the command line reformatting
tool. I don't use IDEs in my regular development work flow (so if
Lazarus has this feature, and it can't be invoked from the command
line, it won't help me).

The default config generated by ptop definitely does not conform to
the standards...

I guess I could write my own ptop.cfg for this... But it seems like
with "Some people might think that the coding style used in the FPC
compiler and base RTL (run-time library) source code is a little bit
strange. But it has been in use for a lot of years and is not subject
to discussion. So take the following as a standard to be used." that
there should be tool configuration that can do that automatically.

With C/C++ even if I'm just working on my own stuff (not in a team), I
can use tools like indent or clang-tidy. I know, FPC is not C/C++, but
is still nice to be able to have some tool enforce a consistent style
regardless what language I'm using.

Sincerely,

Dwight Schauer

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