• OT - ChatGPT is better than I thought.

    From Alan Browne@bitbucket@blackhole.com to comp.sys.mac.apps,comp.sys.mac.system on Sun Oct 15 15:51:57 2023
    From Newsgroup: comp.sys.mac.apps


    Preamble: I suck at C and I'm proficient in Pascal.

    While debugging a piece of C I got into a serious case of pointer mangling.

    So, I asked ChatGPT to prepare a table comparing the two.

    "please prepare a table comparing pointer data types and pointer
    operands between FreePascal and C. Use FreePascal as the starting
    point."

    Resulted in a nicely prepared table and I quickly debugged my program
    (for slow values of quickly).

    But that's not it...

    Then, on a whim: I asked: "
    prepare a comparison of pascal record to C struc where the pascal record
    has elements: a, b: word; c:array [1..10] of real; and next which is a pointer to the record type.

    And it did. And it made an error. So I said to it:
    "I believe you need to first have a pointer to the MyRecord such as: MyRecordPtr = ^MyRecord before the record and next should be of type MyRecordPtr."

    ChatGPT replied:
    "You are absolutely correct, and I apologize for the oversight. In both
    Pascal and C, when you have a pointer to a record or struct within the
    same type definition, you should declare a type for that pointer first.
    Here's the corrected comparison:"

    and put out the correct form (which is - for the case requested):

    type
    MyRecordPtr = ^MyRecord; // Declare a pointer type
    MyRecord = record
    a, b: Word;
    c: array[1..10] of Real;
    next: MyRecordPtr; // Use the pointer type
    end;

    and for C:

    struct MyStruct {
    unsigned short a;
    unsigned short b;
    float c[10];
    struct MyStruct* next;
    };

    (Nasty C letting programmers declare new types and vars on the fly ...
    sigh).
    --
    “Markets can remain irrational longer than your can remain solvent.”
    - John Maynard Keynes.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From moi@findlaybill@blueyonder.co.uk to comp.sys.mac.apps,comp.sys.mac.system on Mon Oct 16 01:56:29 2023
    From Newsgroup: comp.sys.mac.apps

    On 15/10/2023 20:51, Alan Browne wrote:

    Preamble: I suck at C and I'm proficient in Pascal.

    While debugging a piece of C I got into a serious case of pointer mangling.

    So, I asked ChatGPT to prepare a table comparing the two.

       "please prepare a table comparing pointer data types and pointer
        operands between FreePascal and C.  Use FreePascal as the starting
        point."

    Resulted in a nicely prepared table and I quickly debugged my program
    (for slow values of quickly).

    But that's not it...

    Then, on a whim: I asked: "
    prepare a comparison of pascal record to C struc where the pascal record
    has elements:   a, b: word; c:array [1..10] of real; and next which is a pointer to the record type.

    And it did.  And it made an error.  So I said to it:
    "I believe you need to first have a pointer to the MyRecord such as: MyRecordPtr = ^MyRecord before the record and next should be of type MyRecordPtr."

    ChatGPT replied:
    "You are absolutely correct, and I apologize for the oversight. In both Pascal and C, when you have a pointer to a record or struct within the
    same type definition, you should declare a type for that pointer first. Here's the corrected comparison:"

    and put out the correct form (which is - for the case requested):

    type
      MyRecordPtr = ^MyRecord;  // Declare a pointer type
      MyRecord = record
        a, b: Word;
        c: array[1..10] of Real;
        next: MyRecordPtr;  // Use the pointer type
      end;

    and for C:

    struct MyStruct {
      unsigned short a;
      unsigned short b;
      float c[10];
      struct MyStruct* next;
    };

    (Nasty C letting programmers declare new types and vars on the fly ... sigh).


    Hmmm.
    Those declarations do not represent the same types.
    [1..10] is not the same as [10].
    --
    Bill F.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Alan Browne@bitbucket@blackhole.com to comp.sys.mac.apps,comp.sys.mac.system on Mon Oct 16 09:02:51 2023
    From Newsgroup: comp.sys.mac.apps

    On 2023-10-15 20:56, moi wrote:
    On 15/10/2023 20:51, Alan Browne wrote:

    and put out the correct form (which is - for the case requested):

    type
       MyRecordPtr = ^MyRecord;  // Declare a pointer type
       MyRecord = record
         a, b: Word;
         c: array[1..10] of Real;
         next: MyRecordPtr;  // Use the pointer type
       end;

    and for C:

    struct MyStruct {
       unsigned short a;
       unsigned short b;
       float c[10];
       struct MyStruct* next;
    };

    (Nasty C letting programmers declare new types and vars on the fly ...
    sigh).


    Hmmm.
    Those declarations do not represent the same types.

    For Pascal "Real" is platform dependent and can be 32 or 64 bits.

    [1..10] is not the same as [10].

    In C it would be 0 based, but in both you get a 10 element array of real numbers.
    --
    “Markets can remain irrational longer than your can remain solvent.”
    - John Maynard Keynes.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Martha Simons@marthasimons8888@gmail.com to comp.sys.mac.apps on Thu Dec 7 01:40:28 2023
    From Newsgroup: comp.sys.mac.apps

    On Monday, October 16, 2023 at 4:02:56 PM UTC+3, Alan Browne wrote:
    On 2023-10-15 20:56, moi wrote:
    On 15/10/2023 20:51, Alan Browne wrote:

    and put out the correct form (which is - for the case requested):

    type
    MyRecordPtr = ^MyRecord; // Declare a pointer type
    MyRecord = record
    a, b: Word;
    c: array[1..10] of Real;
    next: MyRecordPtr; // Use the pointer type
    end;

    and for C:

    struct MyStruct {
    unsigned short a;
    unsigned short b;
    float c[10];
    struct MyStruct* next;
    };

    (Nasty C letting programmers declare new types and vars on the fly ...
    sigh).


    Hmmm.
    Those declarations do not represent the same types.
    For Pascal "Real" is platform dependent and can be 32 or 64 bits.
    [1..10] is not the same as [10].
    In C it would be 0 based, but in both you get a 10 element array of real numbers.
    --
    “Markets can remain irrational longer than your can remain solvent.”
    - John Maynard Keynes.
    https://chat.openai.com/g/g-2IqDEDp7c-essay-typer https://chat.openai.com/g/g-6sIiosQhh-write-my-essay-bot https://chat.openai.com/g/g-ldMROHWp6-gpt-paraphrasing-tool https://chat.openai.com/g/g-2IqDEDp7c-essay-typer https://chat.openai.com/g/g-wznfN7mwL-chatgpt-essay-writer https://chat.openai.com/g/g-BKo6liIEe-ai-essay-writer-by-eduwriter-ai https://www.bulbapp.com/u/ai-essay-writer
    https://www.bulbapp.com/u/essay-typer
    --- Synchronet 3.20a-Linux NewsLink 1.114