[Gambas-user] I asked chat gpt to write a gambas script, here is what it did

Benoit Minisini benoit.minisini at gambas-basic.org
Tue Feb 14 11:39:16 CET 2023

Le 14/02/2023 à 08:24, Brian G a écrit :
> I asked
> write a gambas script to print primes from 2 to 300
> then added
> please also print the number of primes found
> here is the script it produced
> Public Sub Main() Dim primes As New Integer[] For i As Integer = 2 To 
> 300 Dim isPrime As Boolean = True For j As Integer = 2 To i - 1 If i Mod 
> j = 0 Then isPrime = False Exit Endif Next If isPrime Then primes.Add(i) 
> Endif Next Print "Prime numbers between 2 and 300:" For Each prime As 
> Integer In primes Print prime Next Print "Total number of primes found: 
> " & primes.Count End
> Not elegant but it worked just fine. Ok do we really have a future here!
> spoiler, anything more complex was junk, but still....
> "Failure is the key to success;
>   each mistake teaches us something"  .. Morihei Ueshiba
> Brian G
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

There is something curious in the generated code.

ChatGPT uses the EXIT keyword instead of the BREAK keyword, which is a 

But the EXIT keyword is not documented anywhere in the Gambas 
documentation. And as far as I searched with Google, I didn't find it 
either in any page about Gambas.

So, how could ChatGPT use it if it would be fed by Internet only? Is it 
the same system that produces code and text?

I am suspicious. As usual. :-)

Benoît Minisini.

More information about the User mailing list