Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Avoid strange women and temporary variables.


devel / comp.lang.c / “ChattyG takes a college freshman C/C++ programming exam”

SubjectAuthor
* “ChattyG takes a college freshman C/C++ programmiLynn McGuire
+- Re: “ChattyG takes a college freshman C/C++ proChris M. Thomasson
+* Re: “ChattyG takes a college freshman C/C++ proChristian Gollwitzer
|`- Re: “ChattyG takes a college freshman C/C++ proChris M. Thomasson
+* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|`* Re: “ChattyG takes a college freshman C/C++ progrjak
| `* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|  +- Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|  +* Re: “ChattyG takes a college freshman C/C++ procandycanearter07
|  |+* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|  ||`* Re: “ChattyG takes a college freshman C/C++ progrPavel
|  || +- Re: “ChattyG takes a college freshman C/C++ proRichard Damon
|  || `* Re: “ChattyG takes a college freshman C/C++ proJames Kuyper
|  ||  `* Re: “ChattyG takes a college freshman C/C++ progrPavel
|  ||   +- Re: “ChattyG takes a college freshman C/C++ proRichard Damon
|  ||   `* Re: “ChattyG takes a college freshman C/C++ proJames Kuyper
|  ||    `* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|  ||     `- Re: “ChattyG takes a college freshman C/C++ proJames Kuyper
|  |`* Re: “ChattyG takes a college freshman C/C++ proChris M. Thomasson
|  | +- Re: “ChattyG takes a college freshman C/C++ proRichard Damon
|  | `* Re: “ChattyG takes a college freshman C/C++ proMarioCCCP
|  |  `- Re: “ChattyG takes a college freshman C/C++Keith Thompson
|  +- Re: “ChattyG takes a college freshman C/C++Tim Rentsch
|  +* Re: “ChattyG takes a college freshman C/C++Ben Bacarisse
|  |`* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|  | `- Re: “ChattyG takes a college freshman C/C++Ben Bacarisse
|  `* Re: “ChattyG takes a college freshman C/C++Blue-Maned_Hawk
|   +* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|   |`* Re: “ChattyG takes a college freshman C/C++Blue-Maned_Hawk
|   | `* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|   |  +* Re: “ChattyG takes a college freshman C/C++ programming exam”Scott Lurndal
|   |  |`* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|   |  | +- Re: “ChattyG takes a college freshman C/C++ programming exam”Scott Lurndal
|   |  | `- Re: “ChattyG takes a college freshman C/C++ programming exam”Scott Lurndal
|   |  `* Re: “ChattyG takes a college freshman C/C++Ben Bacarisse
|   |   `* Re: “ChattyG takes a college freshman C/C++Tim Rentsch
|   |    `* Re: “ChattyG takes a college freshman C/C++Ben Bacarisse
|   |     +* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|   |     |+- Re: “ChattyG takes a college freshman C/C++ proDavid Brown
|   |     |`* Re: “ChattyG takes a college freshman C/C++Phil Carmody
|   |     | +- Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|   |     | `- Re: “ChattyG takes a college freshman C/C++Tim Rentsch
|   |     `- Re: “ChattyG takes a college freshman C/C++Tim Rentsch
|   `* Re: “ChattyG takes a college freshman C/C++Keith Thompson
|    +* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|    |`- Re: “ChattyG takes a college freshman C/C++Keith Thompson
|    `- Re: “ChattyG takes a college freshman C/C++ proJames Kuyper
+* Re: “ChattyG takes a college freshman C/C++ proChris M. Thomasson
|+- Re: “ChattyG takes a college freshman C/C++ proChris M. Thomasson
|+- Re: “ChattyG takes a college freshman C/C++Anton Shepelev
|`* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
| `- Re: “ChattyG takes a college freshman C/C++ proChris M. Thomasson
`* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
 `* Re: “ChattyG takes a college freshman C/C++Phil Carmody
  `* Re: “ChattyG takes a college freshman C/C++Anton Shepelev
   `- Re: “ChattyG takes a college freshman C/C++Phil Carmody

Pages:123
“ChattyG takes a college freshman C/C++ programming exam”

<ufne0r$15ple$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29540&group=comp.lang.c#29540

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lynnmcgu...@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: “ChattyG_takes_a_college_freshman_C/C++_programmi
ng_exam”
Date: Thu, 5 Oct 2023 17:40:27 -0500
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <ufne0r$15ple$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 5 Oct 2023 22:40:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3ee43b4d597b03d076430338b6ee12d0";
logging-data="1238702"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1fZAqAafR+cKDedN/eo57t1rNUh9NWg4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:CgjS0/QFp++7uoQw5ByWUBUIixg=
Content-Language: en-US
 by: Lynn McGuire - Thu, 5 Oct 2023 22:40 UTC

“ChattyG takes a college freshman C/C++ programming exam”
https://www.theregister.com/2023/10/03/chatgpt_code_college/

“ChatGPT was put to the test via a series of humdrum freshman C/C++
programming tasks and it passed – though not with honors.”

“According to a Croatian research team, while first-year students can
struggle with some of the assignments, the results [PDF] showed ChatGPT
hitting proficiency targets that ranged between average and that of
experienced programmers. And naturally, as with all college exams,
outcomes can be determined by how questions are worded.”

Lynn

Re: “ChattyG takes a college freshman C/C++ programming exam”

<ufnf1b$15tsq$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29541&group=comp.lang.c#29541

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re:_“ChattyG_takes_a_college_freshman_C/C++_pro
gramming_exam”
Date: Thu, 5 Oct 2023 15:57:46 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ufnf1b$15tsq$1@dont-email.me>
References: <ufne0r$15ple$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 5 Oct 2023 22:57:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cc58f85c75e2a3f0e82b5349446f8c23";
logging-data="1243034"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7wL0ktIoP0prVGLQL4g+57ljXR5WUuLg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:HKyDfdQYYNe6/WSI+pinOToqt4g=
In-Reply-To: <ufne0r$15ple$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 5 Oct 2023 22:57 UTC

On 10/5/2023 3:40 PM, Lynn McGuire wrote:
> “ChattyG takes a college freshman C/C++ programming exam”
>    https://www.theregister.com/2023/10/03/chatgpt_code_college/
>
> “ChatGPT was put to the test via a series of humdrum freshman C/C++
> programming tasks and it passed – though not with honors.”
>
> “According to a Croatian research team, while first-year students can
> struggle with some of the assignments, the results [PDF] showed ChatGPT
> hitting proficiency targets that ranged between average and that of
> experienced programmers. And naturally, as with all college exams,
> outcomes can be determined by how questions are worded.”

If we keep teaching it, it should get better and better... :^o

Re: “ChattyG takes a college freshman C/C++ programming exam”

<ufo6fb$1ddit$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29542&group=comp.lang.c#29542

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aurio...@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re:_“ChattyG_takes_a_college_freshman_C/C++_pro
gramming_exam”
Date: Fri, 6 Oct 2023 07:36:07 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <ufo6fb$1ddit$1@dont-email.me>
References: <ufne0r$15ple$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 6 Oct 2023 05:37:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="817b36916e0a3ff7c49cbcde41c76c5a";
logging-data="1488477"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dkdRAOt3v1rC21So2VHyStIZm4q2dsd8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:1+0Sny+1BxN6vRwnZ9PARWWFCws=
In-Reply-To: <ufne0r$15ple$1@dont-email.me>
 by: Christian Gollwitzer - Fri, 6 Oct 2023 05:36 UTC

Am 06.10.23 um 00:40 schrieb Lynn McGuire:
> “ChattyG takes a college freshman C/C++ programming exam”
>    https://www.theregister.com/2023/10/03/chatgpt_code_college/
>
> “ChatGPT was put to the test via a series of humdrum freshman C/C++
> programming tasks and it passed – though not with honors.”

This is already outdated. I've read the paper and they used the free
version, aka GPT-3.5. They should repeat the same tests with at least
GPT-4. There is a vast improvement especially in programming skill from
3.5 to 4.

In addition, there are open source models available which you can run on
your own computer [1], some of them are specifically finetuned towards
coding - e.g. WizardCoder [2]. The version finetuned to Python
specifically is claimed to surpass GPT-4 in some benchmarks. It can be
downloaded in quantized form, ready to run even CPU-only on a machine
with sufficient RAM [1,3]

[1] https://github.com/ggerganov/llama.cpp
[2] https://github.com/nlpxucan/WizardLM/
[3] https://huggingface.co/TheBloke/WizardCoder-Python-34B-V1.0-GGUF

Christian

Re: “ChattyG takes a college freshman C/C++ programming exam”

<ufplfa$1rmlt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29562&group=comp.lang.c#29562

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re:_“ChattyG_takes_a_college_freshman_C/C++_pro
gramming_exam”
Date: Fri, 6 Oct 2023 11:59:54 -0700
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <ufplfa$1rmlt$1@dont-email.me>
References: <ufne0r$15ple$1@dont-email.me> <ufo6fb$1ddit$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 6 Oct 2023 18:59:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cc58f85c75e2a3f0e82b5349446f8c23";
logging-data="1956541"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MfUWlx2FiTRZcapsXNUV9JC4huRwcXs0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:0ptIqM8CcdX/iRCy10i9f99ObQo=
In-Reply-To: <ufo6fb$1ddit$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Fri, 6 Oct 2023 18:59 UTC

On 10/5/2023 10:36 PM, Christian Gollwitzer wrote:
> Am 06.10.23 um 00:40 schrieb Lynn McGuire:
>> “ChattyG takes a college freshman C/C++ programming exam”
>>     https://www.theregister.com/2023/10/03/chatgpt_code_college/
>>
>> “ChatGPT was put to the test via a series of humdrum freshman C/C++
>> programming tasks and it passed – though not with honors.”
>
> This is already outdated. I've read the paper and they used the free
> version, aka GPT-3.5. They should repeat the same tests with at least
> GPT-4. There is a vast improvement especially in programming skill from
> 3.5 to 4.
>
> In addition, there are open source models available which you can run on
> your own computer [1], some of them are specifically finetuned towards
> coding - e.g. WizardCoder [2]. The version finetuned to Python
> specifically is claimed to surpass GPT-4 in some benchmarks. It can be
> downloaded in quantized form, ready to run even CPU-only on a machine
> with sufficient RAM [1,3]
>
> [1] https://github.com/ggerganov/llama.cpp
> [2] https://github.com/nlpxucan/WizardLM/
> [3] https://huggingface.co/TheBloke/WizardCoder-Python-34B-V1.0-GGUF

Thanks for the links. :^)

Re: “ChattyG takes a college freshman C/C++ programming exam”

<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29590&group=comp.lang.c#29590

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sat, 7 Oct 2023 23:54:48 +0300
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
References: <ufne0r$15ple$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="9d7fdfd6b01c4be7db342d0dc420d4ed";
logging-data="2727996"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Raxw+5YkKeTJ5hgoTlPntHiz3wUa5bME="
Cancel-Lock: sha1:ITVKl/hSbVrSZPXrKk1yCTjWRNQ=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Sat, 7 Oct 2023 20:54 UTC

Lynn McGuire:

> ChattyG takes a college freshman C/C++ programming exam
> https://www.theregister.com/2023/10/03/chatgpt_code_college/

For me, it failed the very trivia:

AS: Can a C function return a pointer to itself?

CG: Yes, a C function can return a pointer to itself. This
is known as a recursive function, where a function calls
itself repeatedly until a certain condition is met. In
this case, the function would return a pointer to the
function itself to enable the recursive call.

I asked that question here:

<https://app.chatty-g.com/>
--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: “ChattyG takes a college freshman C/C++ programming exam”

<uftmh9$2vieq$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29598&group=comp.lang.c#29598

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re:_“ChattyG_takes_a_college_freshman_C/C++_progr
amming_exam”
Date: Sun, 8 Oct 2023 09:42:32 +0200
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <uftmh9$2vieq$1@dont-email.me>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 8 Oct 2023 07:42:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f7a98b247a12ac21761ea562205c97af";
logging-data="3131866"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+q/VL/aLUwtSXhlEwXJ0A4"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
Cancel-Lock: sha1:lRnCNDytYuz0IsVZfKK6m6ItjAw=
In-Reply-To: <20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
 by: jak - Sun, 8 Oct 2023 07:42 UTC

Anton Shepelev ha scritto:
> Lynn McGuire:
>
>> ChattyG takes a college freshman C/C++ programming exam
>> https://www.theregister.com/2023/10/03/chatgpt_code_college/
>
> For me, it failed the very trivia:
>
> AS: Can a C function return a pointer to itself?
>
> CG: Yes, a C function can return a pointer to itself. This
> is known as a recursive function, where a function calls
> itself repeatedly until a certain condition is met. In
> this case, the function would return a pointer to the
> function itself to enable the recursive call.
>
> I asked that question here:
>
> <https://app.chatty-g.com/>
>

The explanation is certainly wrong but it is true that it is possible:

#include <stdio.h>

typedef void (* fptr)(int) ;

fptr foo(int n)
{ printf("Call n. %d\n", n);

return (fptr)foo;
}

int main()
{ fptr p = foo(1);

p(2);

return 0;
}

Out:

Call n. 1
Call n. 2

Re: “ChattyG takes a college freshman C/C++ programming exam”

<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29599&group=comp.lang.c#29599

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sun, 8 Oct 2023 12:55:43 +0300
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="367339d4e143f1bde32c26e30c6cb416";
logging-data="3191275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Wm5/+EaoJpa0Mulgf5aHwMGTRgT7hcaY="
Cancel-Lock: sha1:KP8c6gd9n/oOxLR7rbO6oaHRJcc=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Sun, 8 Oct 2023 09:55 UTC

jak to Anton Shepelev:

> > AS: Can a C function return a pointer to itself?
> > CG: Yes, a C function can return a pointer to itself.
>
> The explanation is certainly wrong but it is true that it
> is possible:

I disagree. A function returns the value of its declared
return type. And although C allows the definition of self-
referential structs, it does allow the declaration of self-
referencial functions.

> #include <stdio.h>
>
> typedef void (* fptr)(int) ;
>
> fptr foo(int n)
> {
> printf("Call n. %d\n", n);
> return (fptr)foo;
> }
>
> int main()
> {
> fptr p = foo(1);
> p(2);
> return 0;
> }
>
> Out:
>
> Call n. 1
> Call n. 2

You are converting void to function pointer fptr. This is
not supported in C. You might have taken advantage of
void*, which is silently convertible to any pointer, but
then again it does not work with function pointer, and C has
not analog of void* for functions pointers, so an explicit
conversion is seem inevitable.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: “ChattyG takes a college freshman C/C++ programming exam”

<20231008130608.bc41b2bedd1c1c458a434c75@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29600&group=comp.lang.c#29600

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sun, 8 Oct 2023 13:06:08 +0300
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <20231008130608.bc41b2bedd1c1c458a434c75@gmail.moc>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="367339d4e143f1bde32c26e30c6cb416";
logging-data="3191275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7h/B3P6ZIv8UtR4+2nNMR8bpHy+CZ1WM="
Cancel-Lock: sha1:VKfpBBg/TC5cHywz8YCVt+spdE0=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Sun, 8 Oct 2023 10:06 UTC

Anton Shepelev:

> And although C allows the definition of self-referential
> structs, it does allow the declaration of self-referencial
> functions.

does /not/ allow.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: “ChattyG takes a college freshman C/C++ programming exam”

<ufu3e1$2voq4$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29601&group=comp.lang.c#29601

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no...@thanks.net (candycanearter07)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re:_“ChattyG_takes_a_college_freshman_C/C++_pro
gramming_exam”
Date: Sun, 8 Oct 2023 06:22:41 -0500
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <ufu3e1$2voq4$2@dont-email.me>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 8 Oct 2023 11:22:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0f9ed7954820e4bc4412baa00edd3bf1";
logging-data="3138372"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CTN+JnGRYBpp47txl93mRP12/6yJLbkmH91kV8frP9g=="
User-Agent: Betterbird (Linux)
Cancel-Lock: sha1:M8oHwiucpKsLkHeIJ+dj4dDR4wA=
Content-Language: en-US
In-Reply-To: <20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
 by: candycanearter07 - Sun, 8 Oct 2023 11:22 UTC

On 10/8/23 04:55, Anton Shepelev wrote:
> I disagree. A function returns the value of its declared
> return type. And although C allows the definition of self-
> referential structs, it does allow the declaration of self-
> referencial functions.

What if you typedef'd the function pointer?

Also, you could probably get away with it by just setting it to a void
pointer and casting the return value to the function pointer.
--
user <candycane> is generated from /dev/urandom

Re: “ChattyG takes a college freshman C/C++ programming exam”

<20231008150352.5dfc8262244889e65a132733@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29603&group=comp.lang.c#29603

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sun, 8 Oct 2023 15:03:52 +0300
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <20231008150352.5dfc8262244889e65a132733@gmail.moc>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<ufu3e1$2voq4$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="367339d4e143f1bde32c26e30c6cb416";
logging-data="3248079"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EuaFPqcK0XlWZw8NpLtu/Ej3aePcOJzA="
Cancel-Lock: sha1:UXiSZJbx2mPXeApkcJRS85pEimo=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Sun, 8 Oct 2023 12:03 UTC

candycanearter07 to Anton Shepelev:

> > And although C allows the definition of self-referential
> > structs, it does [not] allow the declaration of self-
> > referencial functions.
>
> What if you typedef'd the function pointer?

That's what I did:

typedef void (*fp )( void );
typedef stm_fp (*func )( struct my_struct * s, int i );

As you see, the `func' still must return something other
than func...

> Also, you could probably get away with it by just setting
> it to a void pointer and casting the return value to the
> function pointer.

Yes, to a void /function/ pointer, because void* is
incompatible with void(*)(void). And then it is not a
truely recursive declaration, and requires additional work
to invoke. And the following does not compile, of course:

typedef func (*func )( struct my_struct * s, int i );

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: “ChattyG takes a college freshman C/C++ programming exam”

<861qe5cm4r.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29606&group=comp.lang.c#29606

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sun, 08 Oct 2023 05:52:04 -0700
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <861qe5cm4r.fsf@linuxsc.com>
References: <ufne0r$15ple$1@dont-email.me> <20231007235448.25c4986f123c88ff65d2f103@gmail.moc> <uftmh9$2vieq$1@dont-email.me> <20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="757893b9c3d25893c642d7f3314d0d8a";
logging-data="3269357"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GakhrOtLfMNpnqlnH7S1nul/o8IR+Tbo="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:K75x6Hkz9QcT+I8Gt28V6k7QDFk=
sha1:3iBnD4NLCCMUDkQ+TExY/LbOH/8=
 by: Tim Rentsch - Sun, 8 Oct 2023 12:52 UTC

Anton Shepelev <anton.txt@gmail.moc> writes:

> jak to Anton Shepelev:
>
>>> AS: Can a C function return a pointer to itself?
>>> CG: Yes, a C function can return a pointer to itself.
>>
>> The explanation is certainly wrong but it is true that it
>> is possible:
>
> I disagree. A function returns the value of its declared return
> type. And although C allows the definition of self-referential
> structs, it does [not] allow the declaration of self-referencial
> functions.

The question asked is whether a C function can return a pointer to
itself. The answer is Yes: the example given shows a function
that returns a pointer to itself. The type of the returned value
doesn't match the type of a pointer to the function in question,
but the value returned does point to that function. It is true
that in C we cannot declare a self-referential function pointer
type, but that question isn't what was asked; the question asked
is Can a C function return a pointer to itself, which indeed is
possible.

Consider an analogous situation in the data domain:

void *pv = &pv;

There is no question that the variable 'pv' points to itself.
The type of 'pv' does not match the type of '&pv', but still it
is the case that 'pv' points to itself. There is no way in C to
define a pointer type T such that the type T is the same as the
type T* (i.e., a pointer to T), but that result doesn't mean a
pointer variable cannot point to itself. Similarly a function
can be defined that returns a pointer to itself.

Re: “ChattyG takes a college freshman C/C++ programming exam”

<87edi58eb2.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29607&group=comp.lang.c#29607

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Followup: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Followup-To: comp.lang.c
Date: Sun, 08 Oct 2023 13:54:41 +0100
Organization: A noiseless patient Spider
Lines: 89
Message-ID: <87edi58eb2.fsf@bsb.me.uk>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b80d8873568d9e06111403cd7c67c346";
logging-data="3270440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19e3BGG6Gnc3Brfvrq9uyuWPDB5KfxECY8="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:5Dyq3Ho/ym4BxjhqPjuNSkFD8yM=
sha1:Lgmp8irAPuhmCSv2vmIqQ3z9e1Q=
X-BSB-Auth: 1.581c6e214e16b521eb8f.20231008135441BST.87edi58eb2.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 8 Oct 2023 12:54 UTC

Anton Shepelev <anton.txt@gmail.moc> writes:

> jak to Anton Shepelev:
>
>> > AS: Can a C function return a pointer to itself?
>> > CG: Yes, a C function can return a pointer to itself.
>>
>> The explanation is certainly wrong but it is true that it
>> is possible:
>
> I disagree. A function returns the value of its declared
> return type. And although C allows the definition of self-
> referential structs, it does [not] allow the declaration of self-
> referencial functions.

C does not have any way to express the /type/ of a function that returns
a pointer to itself. But self-referential functions (as most people
would use the term) are commonplace, many of them having very dull and
ordinary types!

>> #include <stdio.h>
>>
>> typedef void (* fptr)(int) ;
>>
>> fptr foo(int n)
>> {
>> printf("Call n. %d\n", n);
>> return (fptr)foo;
>> }
>>
>> int main()
>> {
>> fptr p = foo(1);
>> p(2);
>> return 0;
>> }

> You are converting void to function pointer fptr. This is not
> supported in C.

Not in the fragment shown. The conversion is from one
pointer-to-function type (void (*(*)(int))(int)) to another (void
(*)(int)) and that's allowed.

The trouble is that foo and foo(1) have different pointer-to-function
types. If C could express the right type, one could write

foo(1)(2)(3)(4);

but is it stands we can only write

foo(1)(2);

before the types go wrong. A third chained call would try to "call" a
void result.

> You might have taken advantage of
> void*, which is silently convertible to any pointer, but
> then again it does not work with function pointer, and C has
> not analog of void* for functions pointers, so an explicit
> conversion is seem inevitable.

I think it would be reasonable to say that a function /can/ return a
pointer to itself. It's just that the type will be wrong. After all,
we are happy to say that (void *)&some_int_var is a pointer to that int
object even though the type is wrong. To use that pointer to get at the
int object, a conversion is required. Similarly, to use the pointer
returned by a function like foo, a conversion is required. I would do
it like this:

#include <stdio.h>

typedef void (*generic_function_ptr)(void);
typedef generic_function_ptr (*fintp)(int);

generic_function_ptr foo(int n)
{
printf("Call n. %d\n", n);
return foo;
}

int main(void)
{
((fintp)((fintp)foo(1))(2))(3);
}

--
Ben.

Re: “ChattyG takes a college freshman C/C++ programming exam”

<20231008165252.da5fb9bc8a40fce683786c00@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29609&group=comp.lang.c#29609

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sun, 8 Oct 2023 16:52:52 +0300
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <20231008165252.da5fb9bc8a40fce683786c00@gmail.moc>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<87edi58eb2.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="367339d4e143f1bde32c26e30c6cb416";
logging-data="3296025"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wkN8QkXA6y2OI+CkVSxvAJJFeIqCLvq0="
Cancel-Lock: sha1:IQyJ+OvVXpHIRedGHvK9Vyk3LVI=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Sun, 8 Oct 2023 13:52 UTC

Ben Bacarisse:

> C does not have any way to express the /type/ of a
> function that returns a pointer to itself. But self-
> referential functions (as most people would use the term)
> are commonplace, many of them having very dull and
> ordinary types

Yes, but by returning a pointer to itself I meant returning
the correct value of the correct type, and ChattyG
understood it as a question about recursive functions. In
one of the three attempts, it even typed a sample C program
demonstrating recursion!

> >> #include <stdio.h>
> >>
> >> typedef void (* fptr)(int) ;
> >>
> >> fptr foo(int n)
> >> {
> >> printf("Call n. %d\n", n);
> >> return (fptr)foo;
> >> }
> >>
> >> int main()
> >> {
> >> fptr p = foo(1);
> >> p(2);
> >> return 0;
> >> }
>
> > You are converting void to function pointer fptr. This is not
> > supported in C.
>
> Not in the fragment shown.

Indeed. I missed the fact that the return value of `p()' is
never used.

> The conversion is from one pointer-to-function type (void
> (*(*)(int))(int)) to another (void (*)(int)) and that's
> allowed.

Indeed.

> The trouble is that foo and foo(1) have different pointer-
> to-function types.

Which is why I have to cast it. Observe that if
void(*)(void) had similar special treatment in C as void*,
assignment would be possible without casting.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: “ChattyG takes a college freshman C/C++ programming exam”

<8734yl87kj.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29610&group=comp.lang.c#29610

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sun, 08 Oct 2023 16:20:12 +0100
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <8734yl87kj.fsf@bsb.me.uk>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<87edi58eb2.fsf@bsb.me.uk>
<20231008165252.da5fb9bc8a40fce683786c00@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b80d8873568d9e06111403cd7c67c346";
logging-data="3334902"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/FH3RMTS9EMXObBsquJcLAqa3FM7Y9ctE="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:+w28+/53AVNtw3uGyIXHQan5Ci8=
sha1:+qTgZwK3XlXFgwRRG7/iYMzo1zc=
X-BSB-Auth: 1.1250990a74d9094cc7b6.20231008162012BST.8734yl87kj.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 8 Oct 2023 15:20 UTC

Anton Shepelev <anton.txt@gmail.moc> writes:

> Ben Bacarisse:
>
>> C does not have any way to express the /type/ of a
>> function that returns a pointer to itself. But self-
>> referential functions (as most people would use the term)
>> are commonplace, many of them having very dull and
>> ordinary types
>
> Yes, but by returning a pointer to itself I meant returning
> the correct value of the correct type,

Yes. I should have made it clear that I knew your complaint was about
the type. I was clarifying for all readers what the problem was -- the
type not the address.

As I went on to explain, that's stretching the point. With objects, we
accept pointers of the wrong type as being (informally) pointers to that
object, and so (I would say) it is for functions, especially as all
pointer-to-function types can be inter-converted without loss; something
that is not possible with all object pointers.

> and ChattyG
> understood it as a question about recursive functions.

yes, it's answer (apart form the initial "yes") was dead wrong.

--
Ben.

Re: “ChattyG takes a college freshman C/C++ programming exam”

<pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29614&group=comp.lang.c#29614

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sun, 8 Oct 2023 16:37:47 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 8 Oct 2023 16:37:47 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="fc98ecc332487388b7e4ecc06eaef4cd";
logging-data="3317311"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182sLMqOrb6d+R2upW+tBpPOZdxCKk5NJg="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:l08LzQyEY8Biib154mc8IoXySc4=
X-Face: Llanfair­pwllgwyng
yll
­gogeryÂÃ
? ?­chwyrnÂÂÂÂÂÂ
­drobwll­llanÃ
‚Ã
ƒƒƒ‚­tysilioÂÂÂÃ
‚­gogo­goch
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
 by: Blue-Maned_Hawk - Sun, 8 Oct 2023 16:37 UTC

Anton Shepelev wrote:

> You are converting void to function pointer fptr. This is not supported
> in C. You might have taken advantage of void*, which is silently
> convertible to any pointer, but then again it does not work with
> function pointer, and C has not analog of void* for functions pointers,
> so an explicit conversion is seem inevitable.

It mayn't be supported in standard C, but it's a common extension—in fact,
POSIX _requires_ it in order for the dlsym subroutine to work.

--
Blue-Maned_Hawk│shortens to
Hawk│/
blu.mɛin.dÊ°ak/
│he/him/his/himself/Mr.
bluemanedhawk.github.io
Y'know, the one with the thing!

Re: “ChattyG takes a college freshman C/C++ programming exam”

<20231008200536.2aebe46b71bae8b879b5bddb@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29615&group=comp.lang.c#29615

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sun, 8 Oct 2023 20:05:36 +0300
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <20231008200536.2aebe46b71bae8b879b5bddb@gmail.moc>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="367339d4e143f1bde32c26e30c6cb416";
logging-data="3383384"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+pfbVsssbSik0KToBOTj6nLamXi90CyY="
Cancel-Lock: sha1:fkK7L3zt6QfTihWGaLL260r5O6Q=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Sun, 8 Oct 2023 17:05 UTC

Blue-Maned_Hawk:
[Unicode em-dash replaced with --]
> [functions returning pointers to themselves]
> It mayn't be supported in standard C, but it's a common
> extension--in fact, POSIX _requires_ it in order for the
> dlsym subroutine to work.

How so, when casing the return value (from a different
function pointer) does not solve the problem?

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: “ChattyG takes a college freshman C/C++ programming exam”

<ufv02a$398hi$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29616&group=comp.lang.c#29616

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re:_“ChattyG_takes_a_college_freshman_C/C++_pro
gramming_exam”
Date: Sun, 8 Oct 2023 12:31:21 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ufv02a$398hi$1@dont-email.me>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<ufu3e1$2voq4$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 8 Oct 2023 19:31:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ebca3b7c70a663ebe6c771f7b2cfc517";
logging-data="3449394"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Nx/Y4+4qGF9aaeRsm/OF4xMy9dHmG5Lc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:JUh5R8ByMvdKS/RjU8WAf3qZ1DI=
In-Reply-To: <ufu3e1$2voq4$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sun, 8 Oct 2023 19:31 UTC

On 10/8/2023 4:22 AM, candycanearter07 wrote:
> On 10/8/23 04:55, Anton Shepelev wrote:
>> I disagree.  A function returns the value of its declared
>> return type.  And although C allows the definition of self-
>> referential structs, it does allow the declaration of self-
>> referencial functions.
>
> What if you typedef'd the function pointer?
>
> Also, you could probably get away with it by just setting it to a void
> pointer and casting the return value to the function pointer.

Not sure if that's allowed. A function pointer cast to a void pointer,
which in turn is cast back to a function pointer is undefined? What am I
forgetting here?

Re: “ChattyG takes a college freshman C/C++ programming exam”

<87cyxovj92.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29623&group=comp.lang.c#29623

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Sun, 08 Oct 2023 15:31:37 -0700
Organization: None to speak of
Lines: 26
Message-ID: <87cyxovj92.fsf@nosuchdomain.example.com>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="36b234a63abc118e06965f15a687a623";
logging-data="3528715"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CAGn4ME8O6tkdS3v7jCF+"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:q7yXlx2RSAkdxexH4CS5w5v80Ik=
sha1:Q3nBrT8dSrtR1nN8QjZubI+NupQ=
 by: Keith Thompson - Sun, 8 Oct 2023 22:31 UTC

Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> writes:
> Anton Shepelev wrote:
>> You are converting void to function pointer fptr. This is not supported
>> in C. You might have taken advantage of void*, which is silently
>> convertible to any pointer, but then again it does not work with
>> function pointer, and C has not analog of void* for functions pointers,
>> so an explicit conversion is seem inevitable.
>
> It mayn't be supported in standard C, but it's a common extension—in fact,
> POSIX _requires_ it in order for the dlsym subroutine to work.

The POSIX requirement is limited to values returned by dlsym().

https://pubs.opengroup.org/onlinepubs/9699919799/functions/dlsym.html

> The return value from dlsym(), cast to a pointer to the type of the
> named symbol, can be used to call (in the case of a function) or access
> the contents of (in the case of a data object) the named symbol.

An implementation could satisfy that requirement without supporting
void* to function pointer conversions in general.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: “ChattyG takes a college freshman C/C++ programming exam”

<ufvkar$3e7t0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29625&group=comp.lang.c#29625

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: news.x.r...@xoxy.net (Richard Damon)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re:_“ChattyG_takes_a_college_freshman_C/C++_pro
gramming_exam”
Date: Sun, 8 Oct 2023 21:17:15 -0400
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <ufvkar$3e7t0$1@dont-email.me>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<ufu3e1$2voq4$2@dont-email.me> <ufv02a$398hi$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 9 Oct 2023 01:17:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="977b00f5a78722ed66f532c2ab3e9b30";
logging-data="3612576"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZcY2IBTESsltSM+ADvW1VCA+XA9TfBYU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cmHtwXeZH5wvi7aEDVCbla53hxw=
In-Reply-To: <ufv02a$398hi$1@dont-email.me>
Content-Language: en-US
 by: Richard Damon - Mon, 9 Oct 2023 01:17 UTC

On 10/8/23 3:31 PM, Chris M. Thomasson wrote:
> On 10/8/2023 4:22 AM, candycanearter07 wrote:
>> On 10/8/23 04:55, Anton Shepelev wrote:
>>> I disagree.  A function returns the value of its declared
>>> return type.  And although C allows the definition of self-
>>> referential structs, it does allow the declaration of self-
>>> referencial functions.
>>
>> What if you typedef'd the function pointer?
>>
>> Also, you could probably get away with it by just setting it to a void
>> pointer and casting the return value to the function pointer.
>
> Not sure if that's allowed. A function pointer cast to a void pointer,
> which in turn is cast back to a function pointer is undefined? What am I
> forgetting here?

While not specifically called out as undefined behavior, it also isn't
ever said to be allowed.

It will work on the most common processors currently, but I have an
active product using a processor where it will definitely NOT work, as
function pointers are bigger than object pointers.

The Posix standard sort of requires that it works, but only for a
certain set of function pointers, so you can do a work around for
machines that don't actually support it.

One way to acheive the results is define the return type as a pointer to
some defined type of function, and you cast the return value to a
pointer to a function that returns that type of function, and in the
function cast the pointer to itself to that type of function.

i.e.

typedef void (*fret)(); // fret is a simplifed type we can return
typedef fret (*pf)(); // pf is the actual type of the function.

fret func() {
return (fret) func;
}

int main() {

pf p = (pf)func(); // Call the function and cast the return value
pf p2 = (pf)p(); // call the same function from the pointer
}

Note, the standard specifically says we can cast any function pointer
type to another function pointer type and back and get a usable pointer.

(untested code, but should be at least close)

Re: “ChattyG takes a college freshman C/C++ programming exam”

<pan$da5cd$33b40da2$e72bf6b3$e30efcdc@invalid.invalid>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29639&group=comp.lang.c#29639

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Mon, 9 Oct 2023 12:17:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <pan$da5cd$33b40da2$e72bf6b3$e30efcdc@invalid.invalid>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid>
<20231008200536.2aebe46b71bae8b879b5bddb@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 9 Oct 2023 12:17:23 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="aa0f0d6a46ea3d1355477450eb514c69";
logging-data="4070488"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lJPSVN7DY3PDS4WMLessMzSxlyEy7t5A="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:zBj9vPdbdeHqSkdLA/rcB7Rztv4=
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
X-Face: Llanfair­pwllgwyng
yll
­gogeryÂÃ
? ?­chwyrnÂÂÂÂÂÂ
­drobwll­llanÃ
‚Ã
ƒƒƒ‚­tysilioÂÂÂÃ
‚­gogo­goch
 by: Blue-Maned_Hawk - Mon, 9 Oct 2023 12:17 UTC

Anton Shepelev wrote:

> Blue-Maned_Hawk:
> [Unicode em-dash replaced with --]

Why?

>> [functions returning pointers to themselves]
>> It mayn't be supported in standard C, but it's a common extension--in
>> fact, POSIX _requires_ it in order for the dlsym subroutine to work.
>
> How so, when casing the return value (from a different function pointer)
> does not solve the problem?

I was not referring to functions returning pointers to themselves in the
quoted part of my message. I was referring to void * being castable to a
function pointer.

--
Blue-Maned_Hawk│shortens to
Hawk│/
blu.mɛin.dÊ°ak/
│he/him/his/himself/Mr.
bluemanedhawk.github.io
Variably constant!

Re: “ChattyG takes a college freshman C/C++ programming exam”

<20231009230305.adfd0d80c146dc966ab22443@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29645&group=comp.lang.c#29645

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Mon, 9 Oct 2023 23:03:05 +0300
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <20231009230305.adfd0d80c146dc966ab22443@gmail.moc>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid>
<20231008200536.2aebe46b71bae8b879b5bddb@gmail.moc>
<pan$da5cd$33b40da2$e72bf6b3$e30efcdc@invalid.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="404cc1cc3d5d5d1907a85a6573344343";
logging-data="119227"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19MAdOT5Xqqkjv3dJtGyqayoFpWQmbzLM4="
Cancel-Lock: sha1:n/iuEewM1Hqtv3zuam+KTJY/iNM=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Mon, 9 Oct 2023 20:03 UTC

Blue-Maned_Hawk to Anton Shepelev:

> > Blue-Maned_Hawk:
> > [Unicode em-dash replaced with --]
>
> Why?

Oh, it just doesn't go with Usenet, stylistically and
aesthetically. English plain-text is must like
code -- 7-bit-clean. And like code (e.g. for Troff or
LaTeX), there are convensions for dashes, /italic/ text,
<URLs>, &c. Your signature is a mess of Unicode
characters -- terrible :-!

> > > It mayn't be supported in standard C, but it's a
> > > common extension--in fact, POSIX _requires_ it in
> > > order for the dlsym subroutine to work.
> >
> > How so, when casing the return value (from a different
> > function pointer) does not solve the problem?
>
> I was not referring to functions returning pointers to
> themselves in the quoted part of my message. I was
> referring to void * being castable to a function pointer.

Yes, and I asked why the authors of that API decided not to
use the casing that is guarranteed to work, preferring the
dubious casing of void* to function pointers. If /I/ were
the designer (should you be afraid?), I should make it two
functions:

void * dlsym_o(void *restrict handle, const char *restrict name);
void(*)(void) dlsym_f(void *restrict handle, const char *restrict name);

because the caller usually knows what he seeks. If he
doesn't, let it be a single function with a compund return
type. I am not sure what a good way to do it would be,
however, because, having to declare a struct, (with possibly
an union inside) and an enum just for this function may be
bloat, yet:--

enum dlsym_type {dsOBJ, dsFUN, dsNA}; /* the 3rd member optional */

struct dlsym_info
{ char is_found; /* flag, optional */
enum dlsym_type type ; /* optional */
void * obj_ptr ; /* NULL if not found */
void(*)(void) fun_ptr ; /* NULL if not found */
}

`optional' above means the element may be omitted from the
interface. For example, dsNA and .is_found are mutually
exclusive, and both the flag and the enum may be done away
with by requiring that the caller use whichever pointer is
not NULL, and consider the symbol not found if both are
NULL.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: “ChattyG takes a college freshman C/C++ programming exam”

<20231009230651.433f6ac34e4597e3b015f019@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29646&group=comp.lang.c#29646

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Mon, 9 Oct 2023 23:06:51 +0300
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <20231009230651.433f6ac34e4597e3b015f019@gmail.moc>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid>
<87cyxovj92.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="404cc1cc3d5d5d1907a85a6573344343";
logging-data="119227"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/AaV94kG32FgSfPSIKB9ZliislYg4jJ6g="
Cancel-Lock: sha1:O2T1P6cEPitP1yiyHVqOiTK5Tg0=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Mon, 9 Oct 2023 20:06 UTC

Keith Thompson to Blue-Maned_Hawk:

> > The return value from dlsym(), cast to a pointer to the
> > type of the named symbol, can be used to call (in the
> > case of a function) or access the contents of (in the
> > case of a data object) the named symbol.
>
> An implementation could satisfy that requirement without
> supporting void* to function pointer conversions in
> general.

Sounds a like an unnecessary special case and a loophole,
when a standard solution exists:

Message-ID: <20231009230305.adfd0d80c146dc966ab22443@gmail.moc>
Archived : http://al.howardknight.net/?ID=169688196000

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: “ChattyG takes a college freshman C/C++ programming exam”

<OpZUM.25106$0UVe.19441@fx17.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29651&group=comp.lang.c#29651

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: “ChattyG takes a college freshman C/C++ programming exam”
Newsgroups: comp.lang.c++,comp.lang.c
References: <ufne0r$15ple$1@dont-email.me> <20231007235448.25c4986f123c88ff65d2f103@gmail.moc> <uftmh9$2vieq$1@dont-email.me> <20231008125543.518cab44cdefed7e8af393c8@gmail.moc> <pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid> <20231008200536.2aebe46b71bae8b879b5bddb@gmail.moc> <pan$da5cd$33b40da2$e72bf6b3$e30efcdc@invalid.invalid> <20231009230305.adfd0d80c146dc966ab22443@gmail.moc>
Lines: 38
Message-ID: <OpZUM.25106$0UVe.19441@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 09 Oct 2023 20:30:38 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 09 Oct 2023 20:30:38 GMT
X-Received-Bytes: 2587
 by: Scott Lurndal - Mon, 9 Oct 2023 20:30 UTC

Anton Shepelev <anton.txt@gmail.moc> writes:
>Blue-Maned_Hawk to Anton Shepelev:
>
>> > Blue-Maned_Hawk:
>> > [Unicode em-dash replaced with --]
>>
>> Why?
>
>Oh, it just doesn't go with Usenet, stylistically and
>aesthetically. English plain-text is must like
>code -- 7-bit-clean. And like code (e.g. for Troff or
>LaTeX), there are convensions for dashes, /italic/ text,
><URLs>, &c. Your signature is a mess of Unicode
>characters -- terrible :-!
>
>> > > It mayn't be supported in standard C, but it's a
>> > > common extension--in fact, POSIX _requires_ it in
>> > > order for the dlsym subroutine to work.
>> >
>> > How so, when casing the return value (from a different
>> > function pointer) does not solve the problem?
>>
>> I was not referring to functions returning pointers to
>> themselves in the quoted part of my message. I was
>> referring to void * being castable to a function pointer.
>
>Yes, and I asked why the authors of that API decided not to
>use the casing that is guarranteed to work, preferring the
>dubious casing of void* to function pointers.

Because all POSIX systems of the day had identically
sized function and object pointers, and the committee possibly
did not believe that there would ever be a future architecture
for which POSIX would be useful that had a distinction
between object and function pointers and they had little
interest in obsoleting existing code.

dlsym showed up about 1990 in SVR4, coming from SunOS IIRC.

Re: “ChattyG takes a college freshman C/C++ programming exam”

<20231009234509.8c1887fd8b98e4db058726c5@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29653&group=comp.lang.c#29653

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Mon, 9 Oct 2023 23:45:09 +0300
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <20231009234509.8c1887fd8b98e4db058726c5@gmail.moc>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid>
<20231008200536.2aebe46b71bae8b879b5bddb@gmail.moc>
<pan$da5cd$33b40da2$e72bf6b3$e30efcdc@invalid.invalid>
<20231009230305.adfd0d80c146dc966ab22443@gmail.moc>
<OpZUM.25106$0UVe.19441@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="404cc1cc3d5d5d1907a85a6573344343";
logging-data="138285"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lSeHBjJbgSuSHd2jPu+QqNuzhp0AVeoM="
Cancel-Lock: sha1:oaReifS4IOdSyWSPKk8AfV79Rq8=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Mon, 9 Oct 2023 20:45 UTC

Scott Lurndal to Anton Shepelev:

> > Yes, and I asked why the authors of that API decided not
> > to use the casing that is guarranteed to work,
> > preferring the dubious casing of void* to function
> > pointers.
>
> Because all POSIX systems of the day had identically sized
> function and object pointers, and the committee possibly
> did not believe that there would ever be a future
> architecture for which POSIX would be useful that had a
> distinction between object and function pointers

Sounds like a instance myopic thinking. Compliance with the
Standard is always the safest road into the future. ("Write
it down in your notebooks, gentlemen!"[1])

> and they had little interest in obsoleting existing code.
>
> dlsym showed up about 1990 in SVR4, coming from SunOS
> IIRC.

What was there to obsolete in 1990, or did you mean ever
since?
____________________
1. /One-storied America/

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: “ChattyG takes a college freshman C/C++ programming exam”

<878r8b7cb8.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29654&group=comp.lang.c#29654

  copy link   Newsgroups: comp.lang.c++ comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: “ChattyG takes a college freshman C/C++
programming exam”
Date: Mon, 09 Oct 2023 21:47:39 +0100
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <878r8b7cb8.fsf@bsb.me.uk>
References: <ufne0r$15ple$1@dont-email.me>
<20231007235448.25c4986f123c88ff65d2f103@gmail.moc>
<uftmh9$2vieq$1@dont-email.me>
<20231008125543.518cab44cdefed7e8af393c8@gmail.moc>
<pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid>
<20231008200536.2aebe46b71bae8b879b5bddb@gmail.moc>
<pan$da5cd$33b40da2$e72bf6b3$e30efcdc@invalid.invalid>
<20231009230305.adfd0d80c146dc966ab22443@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="39501676898f3c17ed4e55effbe9740e";
logging-data="139256"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Mxe8UqOXC6zS9RS3K/Ihf2su5xIUw0fo="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:/wuSAXkjy41sOBcPycotZAQdmlQ=
sha1:ENnaYK4QwcTI9r71w8RshO2I74g=
X-BSB-Auth: 1.4e065a5fd48fb0180d82.20231009214739BST.878r8b7cb8.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 9 Oct 2023 20:47 UTC

Anton Shepelev <anton.txt@gmail.moc> writes:

> Blue-Maned_Hawk to Anton Shepelev:
>
>> > Blue-Maned_Hawk:
>> > [Unicode em-dash replaced with --]
>>
>> Why?
>
> Oh, it just doesn't go with Usenet, stylistically and
> aesthetically.

What is aesthetically wrong about using a bullet-point marker? What
is stylistically wrong about writing accented characters?

> English plain-text is much like
> code -- 7-bit-clean.

That's circular. By "plain-text" you mean 7-bit clean. Texts written
in English have, traditionally, used all sort of typographical marks,
and it has always been considered goof style to write correctly.
Phonetic script should be rendered correctly. Foreign words should be
rendered correctly.

What many people think of a "plain" English text is just what we've been
forced to write by clunky technology; first typewriters and then
computers. We should more on. There was a time when people would moan
if I sent a file with lower case letters in it because it could not be
rendered on a CDC mainframe. Come on, it's the 21st century.

> And like code (e.g. for Troff or
> LaTeX), there are convensions for dashes, /italic/ text,
> <URLs>, &c. Your signature is a mess of Unicode
> characters -- terrible :-!

BMH has posted a bad signature. It's not UTF-8 encoded Unicode at all,
despite what the header says. It is what's called mojibake.

In fact, properly rendered, his sig just contains a few phonetic letters
and, oddly, some "BOX DRAWINGS LIGHT VERTICAL" lines for which I would
have used | (despite what I wrote above).

Of course the fact that he did not post it correctly could be seen as
undermining my case, but I take as a further call to action: come on
BMH, buck up and get it right!

>> I was not referring to functions returning pointers to
>> themselves in the quoted part of my message. I was
>> referring to void * being castable to a function pointer.
>
> Yes, and I asked why the authors of that API decided not to
> use the casing that is guarranteed to work, preferring the
> dubious casing of void* to function pointers.

Almost certainly a case that the designers knew the system involved and
were solving an immediate problem for one particular OS on a limited
class of machines (SunOS, I think). They never thought that people
would still be using it, much less critiquing it, 40 years later!

--
Ben.

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor