Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Life. Don't talk to me about life. -- Marvin the Paranoid Android


devel / comp.lang.c / Why is glibc not extensive?

SubjectAuthor
* Why is glibc not extensive?Amit
+* Re: Why is glibc not extensive?Stefan Ram
|`- Re: Why is glibc not extensive?Stefan Ram
+* Re: Why is glibc not extensive?Bart
|`* Re: Why is glibc not extensive?A
| +- Re: Why is glibc not extensive?A
| +- Re: Why is glibc not extensive?Bart
| +- Re: Why is glibc not extensive?Ben Bacarisse
| `* Re: Why is glibc not extensive?David Brown
|  +* Re: Why is glibc not extensive?A
|  |`* Re: Why is glibc not extensive?David Brown
|  | `* Re: Why is glibc not extensive?A
|  |  +* Re: Why is glibc not extensive?David Brown
|  |  |`- Re: Why is glibc not extensive?A
|  |  +* Re: Why is glibc not extensive?Bart
|  |  |`* Re: Why is glibc not extensive?David Brown
|  |  | `- Bart (Was: Why is glibc not extensive?)Kenny McCormack
|  |  `* Re: Why is glibc not extensive?Michael S
|  |   `* Re: Why is glibc not extensive?Tim Rentsch
|  |    `* Re: Why is glibc not extensive?Michael S
|  |     +* Re: Why is glibc not extensive?Kaz Kylheku
|  |     |+- Re: Why is glibc not extensive?Scott Lurndal
|  |     |`* Re: Why is glibc not extensive?BGB
|  |     | `* Re: Why is glibc not extensive?Bart
|  |     |  `- Re: Why is glibc not extensive?BGB
|  |     `- Re: Why is glibc not extensive?Tim Rentsch
|  `- Re: Why is glibc not extensive?BGB
`* Re: Why is glibc not extensive?Bonita Montero
 `* Re: Why is glibc not extensive?Kenny McCormack
  `- Re: Why is glibc not extensive?BGB

Pages:12
Why is glibc not extensive?

<c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:a9d2:0:b0:6ee:3a2e:9fb1 with SMTP id s201-20020a37a9d2000000b006ee3a2e9fb1mr599533qke.139.1668666717092;
Wed, 16 Nov 2022 22:31:57 -0800 (PST)
X-Received: by 2002:ac8:7c2:0:b0:3a5:4c54:c0a6 with SMTP id
m2-20020ac807c2000000b003a54c54c0a6mr1050685qth.651.1668666716889; Wed, 16
Nov 2022 22:31:56 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 16 Nov 2022 22:31:56 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=103.55.96.98; posting-account=2Euk4AoAAAANbkJqWN4ELB-XnIDDEocl
NNTP-Posting-Host: 103.55.96.98
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
Subject: Why is glibc not extensive?
From: amitchou...@gmail.com (Amit)
Injection-Date: Thu, 17 Nov 2022 06:31:57 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 8
 by: Amit - Thu, 17 Nov 2022 06:31 UTC

Hi,

In my opinion, glibc should have support for maps, sets, balanced binary trees, many more string functions, etc. (I know tree and hash are there in glibc), so that developers don't have to implement them themselves, thus saving lots of man hours all over the world. This will also make C more user friendly like C++ and Java.

Amit

Re: Why is glibc not extensive?

<maps-20221117105039@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: 17 Nov 2022 09:51:14 GMT
Organization: Stefan Ram
Lines: 29
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <maps-20221117105039@ram.dialup.fu-berlin.de>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 2tNTbUTTCew0+VLLUm6J8wGawzLdmxVjCFBzVlzrwK9RAI
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Thu, 17 Nov 2022 09:51 UTC

Amit <amitchoudhary0523@gmail.com> writes:
>In my opinion, glibc should have support for maps, sets, balanced binary
>trees, many more string functions, etc.

That would make C what I call an "application programming language".

C is a system programming language, intended to be used to /implement/
such things as maps for application programming languages or to be
used for programming tasks where one can get by without such things.

Often, C programmers cheat a bit, choosing what /can/ be done in C.
For instance, the Python program

map ={ 'a': a, 'b': b }
map[ c ]()

could be translated into

if( !strcmp( c, "a" ))a();
else if( !strcmp( c, "b" ))b();
else unknown_name_error();

. While a sequence of comparisons should be slower than using a hash
map, the C version in practice will probably still be faster.

If you want to have maps you can either choose a C library for maps,
C++, or some application programming language.

Re: Why is glibc not extensive?

<vector-20221117111733@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: 17 Nov 2022 10:18:12 GMT
Organization: Stefan Ram
Lines: 17
Expires: 1 Sep 2023 11:59:58 GMT
Message-ID: <vector-20221117111733@ram.dialup.fu-berlin.de>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com> <maps-20221117105039@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 178yZQ0F1QIQt9N8lYQmOQ9/XZqQf4X6WyuNcCOlBlGHe1
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Thu, 17 Nov 2022 10:18 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>If you want to have maps you can either choose a C library for maps,
>C++, or some application programming language.

BTW: In C++, they find that usually ::std::vector is faster
than any other container, even for those cases where the
other containers seem to match the requirements better.

Video "Modern C++: What You Need to Know" (2014) - Herb Sutter
(starting from the about minute twenty three - "Real arrays")

So, if one wants to implement any container in C, it might
be sensible to start with something like ::std::vector.
Maybe this is all one ever needs. For a start, one could
use this for strings.

Re: Why is glibc not extensive?

<tl5bi5$laf$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!uabYU4OOdxBKlV2hpj27FQ.user.46.165.242.75.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Thu, 17 Nov 2022 13:05:10 +0000
Organization: Aioe.org NNTP Server
Message-ID: <tl5bi5$laf$1@gioia.aioe.org>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="21839"; posting-host="uabYU4OOdxBKlV2hpj27FQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.2
X-Notice: Filtered by postfilter v. 0.9.2
 by: Bart - Thu, 17 Nov 2022 13:05 UTC

On 17/11/2022 06:31, Amit wrote:
> Hi,
>
> In my opinion, glibc should have support for maps, sets, balanced binary trees, many more string functions, etc. (I know tree and hash are there in glibc), so that developers don't have to implement them themselves, thus saving lots of man hours all over the world. This will also make C more user friendly like C++ and Java.

There must be 1000s of such libraries already available, all doing
things slightly differently, with different choices and with different
applications in mind.

You want the maintainers of C to decide which ones to build in to the
standard language? (Maybe decide which of umpteen GUI libraries to
include too.)

People use C /because/ it has that flexibility to use any library or to
implement your own.

Anyway a lot of your suggestions really demand generic solutions, and C
doesn't have generic types. For those, there are myriad more assorted
ways to add those to C, but the results are usually ungainly and painful
to use.

C is just not suited for such things.

Re: Why is glibc not extensive?

<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a0c:ec88:0:b0:4b1:9054:b54a with SMTP id u8-20020a0cec88000000b004b19054b54amr2221270qvo.122.1668691117809;
Thu, 17 Nov 2022 05:18:37 -0800 (PST)
X-Received: by 2002:a05:620a:1225:b0:6ed:28b:764d with SMTP id
v5-20020a05620a122500b006ed028b764dmr1550855qkj.328.1668691117586; Thu, 17
Nov 2022 05:18:37 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 17 Nov 2022 05:18:37 -0800 (PST)
In-Reply-To: <tl5bi5$laf$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=103.55.96.98; posting-account=VlS9cQoAAAAdP9kc5s4uYeJeZh3syM8E
NNTP-Posting-Host: 103.55.96.98
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com> <tl5bi5$laf$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
Subject: Re: Why is glibc not extensive?
From: amit2342...@gmail.com (A)
Injection-Date: Thu, 17 Nov 2022 13:18:37 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3582
 by: A - Thu, 17 Nov 2022 13:18 UTC

On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
> On 17/11/2022 06:31, Amit wrote:
>
> Anyway a lot of your suggestions really demand generic solutions, and C
> doesn't have generic types. For those, there are myriad more assorted
> ways to add those to C, but the results are usually ungainly and painful
> to use.
>
> C is just not suited for such things.

Generics can be implemented in C without much hassle.

I am currently implementing C++ STL in C. And the my data structures are generic - any type of data can be used just like in C++ STL.

The following is part of my header file which lists how I achieved generics in C:

struct element
{
void *data;
long data_len;
struct element *next;
};

typedef void (*call_function_before_deleting_data)(struct element *);
typedef void (*compare_elements_function)(struct element *, struct element *);

struct generic_unordered_set_container
{
struct element *first;
struct element *fi; // fi stands for forward iterator
long total_number_of_elements;
// callback functions
call_function_before_deleting_data cfbdd_callback_function;
compare_elements_function ce_function;
// to be thread-safe
pthread_mutex_t mtx;
pthread_mutexattr_t mtx_attr;
};

Amit

Re: Why is glibc not extensive?

<117d77d9-292e-4e10-999f-191185c0ac4cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:4d4e:0:b0:39c:bdd5:30b7 with SMTP id x14-20020ac84d4e000000b0039cbdd530b7mr2136408qtv.213.1668691453665;
Thu, 17 Nov 2022 05:24:13 -0800 (PST)
X-Received: by 2002:a05:622a:1a15:b0:35b:ae82:5e33 with SMTP id
f21-20020a05622a1a1500b0035bae825e33mr2101474qtb.328.1668691453508; Thu, 17
Nov 2022 05:24:13 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 17 Nov 2022 05:24:13 -0800 (PST)
In-Reply-To: <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=103.55.96.98; posting-account=VlS9cQoAAAAdP9kc5s4uYeJeZh3syM8E
NNTP-Posting-Host: 103.55.96.98
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org> <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <117d77d9-292e-4e10-999f-191185c0ac4cn@googlegroups.com>
Subject: Re: Why is glibc not extensive?
From: amit2342...@gmail.com (A)
Injection-Date: Thu, 17 Nov 2022 13:24:13 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3017
 by: A - Thu, 17 Nov 2022 13:24 UTC

On Thursday, 17 November 2022 at 18:48:45 UTC+5:30, A wrote:
> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
> > On 17/11/2022 06:31, Amit wrote:
> >
> > Anyway a lot of your suggestions really demand generic solutions, and C
> > doesn't have generic types. For those, there are myriad more assorted
> > ways to add those to C, but the results are usually ungainly and painful
> > to use.
> >
> > C is just not suited for such things.
> Generics can be implemented in C without much hassle.
>
> I am currently implementing C++ STL in C. And the my data structures are generic - any type of data can be used just like in C++ STL.
>
> The following is part of my header file which lists how I achieved generics in C:
>
> struct element
> {
> void *data;
> long data_len;
> struct element *next;
> };
>
> typedef void (*call_function_before_deleting_data)(struct element *);
> typedef void (*compare_elements_function)(struct element *, struct element *);
>
> struct generic_unordered_set_container
> {
> struct element *first;
> struct element *fi; // fi stands for forward iterator
> long total_number_of_elements;
> // callback functions
> call_function_before_deleting_data cfbdd_callback_function;
> compare_elements_function ce_function;
> // to be thread-safe
> pthread_mutex_t mtx;
> pthread_mutexattr_t mtx_attr;
> };
>
> Amit

I forgot to add that data will copy user data irrespective of user data being a pointer or a concrete structure.

Something like this:

int add_new_element(struct generic_unordered_set_container *gusc_ptr, void *data, long data_len)
{

_some_code_

nddt->data_len = data_len;
memcpy(nddt->data, data, (size_t)(nddt->data_len));

_some_code_

}

Amit

Re: Why is glibc not extensive?

<tl5el6$3uq$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!uabYU4OOdxBKlV2hpj27FQ.user.46.165.242.75.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Thu, 17 Nov 2022 13:57:59 +0000
Organization: Aioe.org NNTP Server
Message-ID: <tl5el6$3uq$1@gioia.aioe.org>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org>
<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="4058"; posting-host="uabYU4OOdxBKlV2hpj27FQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.2
X-Notice: Filtered by postfilter v. 0.9.2
 by: Bart - Thu, 17 Nov 2022 13:57 UTC

On 17/11/2022 13:18, A wrote:
> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
>> On 17/11/2022 06:31, Amit wrote:
>>
>> Anyway a lot of your suggestions really demand generic solutions, and C
>> doesn't have generic types. For those, there are myriad more assorted
>> ways to add those to C, but the results are usually ungainly and painful
>> to use.
>>
>> C is just not suited for such things.
>
> Generics can be implemented in C without much hassle.
>
> I am currently implementing C++ STL in C. And the my data structures are generic - any type of data can be used just like in C++ STL.

As I said, lots of people have attemted this. If I tried it, I would do
it differently from your, with different trade-offs. Which one should
standard C have?

>
> The following is part of my header file which lists how I achieved generics in C:
>
> struct element
> {
> void *data;
> long data_len;
> struct element *next;
> };
>
> typedef void (*call_function_before_deleting_data)(struct element *);
> typedef void (*compare_elements_function)(struct element *, struct element *);
>
> struct generic_unordered_set_container
> {
> struct element *first;
> struct element *fi; // fi stands for forward iterator
> long total_number_of_elements;
> // callback functions
> call_function_before_deleting_data cfbdd_callback_function;

> compare_elements_function ce_function;
> // to be thread-safe
> pthread_mutex_t mtx;
> pthread_mutexattr_t mtx_attr;
> };

What does an example of use actually look like, compared with C++?

C++ has famously long-winded and 'busy' syntax; is yours going to be
longer or shorter?

And why would somebody use this particular library, in C, compared to
just using C++?

For example, a simple array like this:

vector<int> A = {10,20,30,40};

Re: Why is glibc not extensive?

<871qq1tsvr.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Thu, 17 Nov 2022 17:04:08 +0000
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <871qq1tsvr.fsf@bsb.me.uk>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org>
<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="02d8a48b4b4459e082666a44d26f5c0e";
logging-data="2832161"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mUR9QQhV+kHz1QcoSwmbIxQiseKtiCnk="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:TVYNE/oAKODHvBdWA4GjDITpcoY=
sha1:P+MbHBKYtyFsZB7mMhq5v/dFvrc=
X-BSB-Auth: 1.b9a642e769cda05bb51b.20221117170408GMT.871qq1tsvr.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 17 Nov 2022 17:04 UTC

A <amit234234234234@gmail.com> writes:

> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
>> On 17/11/2022 06:31, Amit wrote:
>>
>> Anyway a lot of your suggestions really demand generic solutions, and C
>> doesn't have generic types. For those, there are myriad more assorted
>> ways to add those to C, but the results are usually ungainly and painful
>> to use.
>>
>> C is just not suited for such things.
>
> Generics can be implemented in C without much hassle.

The code you posted shows that it really is quite a lot of hassle.

> I am currently implementing C++ STL in C. And the my data structures
> are generic - any type of data can be used just like in C++ STL.

C++ containers have type checking and automatic destruction both of
which are big wins. Why not use C++ rather than try to write a poor
man's STL in C?

--
Ben.

Re: Why is glibc not extensive?

<tl5t5c$2mnpk$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Thu, 17 Nov 2022 19:05:38 +0100
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <tl5t5c$2mnpk$1@dont-email.me>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 17 Nov 2022 18:05:32 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="70d9e14b40bbbc4596e200ffb1e6e4a3";
logging-data="2842420"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WrSlSbwbVjCzI5VHE/iyIKhHgD1Goqwk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.2
Cancel-Lock: sha1:c44/lCJPobZgN0OGpoJeWn6zCu0=
Content-Language: de-DE
In-Reply-To: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
 by: Bonita Montero - Thu, 17 Nov 2022 18:05 UTC

Am 17.11.2022 um 07:31 schrieb Amit:
> Hi,
>
> In my opinion, glibc should have support for maps, sets, balanced binary trees, many more string functions, etc. (I know tree and hash are there in glibc), so that developers don't have to implement them themselves, thus saving lots of man hours all over the world. This will also make C more user friendly like C++ and Java.
>
> Amit

glibc is for everything the C language supports as well as
Posix- SysV-,BSD- and Linux-spefic APIs. As C doesn't support
anything you suggest your idea doesn't fit.

Re: Why is glibc not extensive?

<tl7eiv$6jrs$1@news.xmission.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Fri, 18 Nov 2022 08:09:03 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tl7eiv$6jrs$1@news.xmission.com>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com> <tl5t5c$2mnpk$1@dont-email.me>
Injection-Date: Fri, 18 Nov 2022 08:09:03 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="216956"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 18 Nov 2022 08:09 UTC

In article <tl5t5c$2mnpk$1@dont-email.me>,
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 17.11.2022 um 07:31 schrieb Amit:
>> Hi,
>>
>>In my opinion, glibc should have support for maps, sets, balanced
>>binary trees, many more string functions, etc. (I know tree and hash
>>are there in glibc), so that developers don't have to implement them
>>themselves, thus saving lots of man hours all over the world. This
>>will also make C more user friendly like C++ and Java.
>>
>> Amit
>
>glibc is for everything the C language supports as well as
>Posix- SysV-,BSD- and Linux-spefic APIs. As C doesn't support
>anything you suggest your idea doesn't fit.
>

I heard about this time, back in 1993 or thereabouts, where someone made a
Usenet suggestion that something should be added to the existing libraries
in either C or Unix (not sure which, it was a long time ago) and at least
one responder *didn't* crap all over the idea.

Hasn't happened since, of course...

--
There's nothing more American than demanding to carry an AR-15 to
"protect yourself" but refusing to wear a mask to protect everyone else.

Re: Why is glibc not extensive?

<tl7fve$2tbg8$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Fri, 18 Nov 2022 09:32:45 +0100
Organization: A noiseless patient Spider
Lines: 76
Message-ID: <tl7fve$2tbg8$1@dont-email.me>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org>
<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Nov 2022 08:32:46 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="af11441be165e54e49ca43a3f5870de0";
logging-data="3059208"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XX8HaR+WewJEY1QfaweyjjCsp/4v7PH0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:NcmnKZzChvsB+RkLaIZZPLGGJ8I=
In-Reply-To: <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Fri, 18 Nov 2022 08:32 UTC

On 17/11/2022 14:18, A wrote:
> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
>> On 17/11/2022 06:31, Amit wrote:
>>
>> Anyway a lot of your suggestions really demand generic solutions, and C
>> doesn't have generic types. For those, there are myriad more assorted
>> ways to add those to C, but the results are usually ungainly and painful
>> to use.
>>
>> C is just not suited for such things.
>
> Generics can be implemented in C without much hassle.
>

No, they cannot.

> I am currently implementing C++ STL in C. And the my data structures are generic - any type of data can be used just like in C++ STL.
>

No, they cannot.

Of course you can make generic containers in C, but you cannot approach
the user convenience, safety, or efficiency that is found in other
languages that have better support for this kind of thing. You have no
choice but to use generic "void *" pointers, long names, and awkward syntax.

If you have a vector of "widgets" in a programming language, and you try
to add a "whatsit" to it, there are basically three things that can happen :

1. The compiler will complain (that's the C++ style).

2. The language can happily work correctly with a vector containing
"widgets" and "whatsits" and treat them safely (even if the application
code gets confused). That's Python style.

3. The language can happily accept the nonsense at compile time, perhaps
copying only bits of the "whatsit" or including rubbish in the vector.
No one knows what will happen, and as you try to use the "whatsit" as
though it were a "widget", you can cause all kinds of corruption or
problems that turn up as unexpected effects in completely different
parts of the code making debugging a nightmare. That's C "void*" style.

Then you have user convenience. If you want to set the field "x" in
element "i" of vector "v" to 1, in C++ you write "v[i].x = 1;". In C
"generic containers", you write:

widget * p;
vector_get_as_reference(v, i, &p);
p->x = 1;

Or maybe you have something with macro wrappers :

VECTOR_GET_AS_REF(v, i, widget)->x = 1;

I haven't even covered whether you should be holding copies of the
widget structures in the vector, or references to them, or references
with reference counters, or how you might handle allocation of new
widgets and freeing of old ones.

You /can/ do it all in C, but the usage of the containers will not be
comparable in terms of convenience for the programmer, safety, or
efficiency.

The norm in C is to make the lists or containers you need for the data
types you need and the features you need. Usually that's not too hard,
and the results are hugely nicer to use and more efficient than any C
generic containers.

That doesn't mean generic containers in C are a bad idea - especially
more advanced containers that are harder for programmers to write
themselves. But don't kid yourself that you'll get something as nice as
C++'s standard containers, or the containers built into most higher
level languages.

Re: Why is glibc not extensive?

<81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:41d0:0:b0:39c:b702:8ec with SMTP id o16-20020ac841d0000000b0039cb70208ecmr5793400qtm.253.1668767556335;
Fri, 18 Nov 2022 02:32:36 -0800 (PST)
X-Received: by 2002:ac8:7091:0:b0:3a5:2793:c242 with SMTP id
y17-20020ac87091000000b003a52793c242mr6061895qto.14.1668767556151; Fri, 18
Nov 2022 02:32:36 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 18 Nov 2022 02:32:35 -0800 (PST)
In-Reply-To: <tl7fve$2tbg8$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=103.55.96.98; posting-account=VlS9cQoAAAAdP9kc5s4uYeJeZh3syM8E
NNTP-Posting-Host: 103.55.96.98
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org> <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
Subject: Re: Why is glibc not extensive?
From: amit2342...@gmail.com (A)
Injection-Date: Fri, 18 Nov 2022 10:32:36 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3010
 by: A - Fri, 18 Nov 2022 10:32 UTC

On Friday, 18 November 2022 at 14:03:00 UTC+5:30, David Brown wrote:
> On 17/11/2022 14:18, A wrote:
> > On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
> >> On 17/11/2022 06:31, Amit wrote:
> >>
> >> Anyway a lot of your suggestions really demand generic solutions, and C
> >> doesn't have generic types. For those, there are myriad more assorted
> >> ways to add those to C, but the results are usually ungainly and painful
> >> to use.
> >>
> >> C is just not suited for such things.
> >
> > Generics can be implemented in C without much hassle.
> >
> No, they cannot.

I am implementing them and for me it is not a hassle.

> > I am currently implementing C++ STL in C. And the my data structures are generic - any type of data can be used just like in C++ STL.
> >
> No, they cannot.
>

Why? You can save any kind of data in void *. Psuedocode is below:

save(void *x, len)
{ //assume, memory, etc. is allocated.
memcpy(generic_data_struct->data, data, len);
}

User code:

struct a temp;
save(&temp, sizeof(temp));

> Of course you can make generic containers in C, but you cannot approach
> the user convenience, safety, or efficiency that is found in other
> languages that have better support for this kind of thing. You have no
> choice but to use generic "void *" pointers, long names, and awkward syntax.

I am not trying to do all those - safety, or efficiency, etc. I am just implementing them because I want to do this in my free time. And, in case, someone uses my code then it will be a bonus.

Why would the syntax be awkward? It is straight forward C syntax.

The following lines of code don't look awkward to me:

memcpy(generic_data_struct->data, data, len);
save(&temp, sizeof(temp));

Amit

Re: Why is glibc not extensive?

<tl7sm7$2uat7$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Fri, 18 Nov 2022 13:09:43 +0100
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <tl7sm7$2uat7$1@dont-email.me>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org>
<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me>
<81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Nov 2022 12:09:43 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="af11441be165e54e49ca43a3f5870de0";
logging-data="3091367"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5UzyV7CsdKhH3jvJ+uQudwVJ1Ftnf98U="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:devLj8ewnV/r9JflCSZdLgmvgmU=
Content-Language: en-GB
In-Reply-To: <81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
 by: David Brown - Fri, 18 Nov 2022 12:09 UTC

On 18/11/2022 11:32, A wrote:
>
> On Friday, 18 November 2022 at 14:03:00 UTC+5:30, David Brown wrote:
>> On 17/11/2022 14:18, A wrote:
>>> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
>>>> On 17/11/2022 06:31, Amit wrote:
>>>>
>>>> Anyway a lot of your suggestions really demand generic solutions, and C
>>>> doesn't have generic types. For those, there are myriad more assorted
>>>> ways to add those to C, but the results are usually ungainly and painful
>>>> to use.
>>>>
>>>> C is just not suited for such things.
>>>
>>> Generics can be implemented in C without much hassle.
>>>
>> No, they cannot.
>
> I am implementing them and for me it is not a hassle.
>
>
>
>>> I am currently implementing C++ STL in C. And the my data structures are generic - any type of data can be used just like in C++ STL.
>>>
>> No, they cannot.
>>
>
> Why? You can save any kind of data in void *.

Exactly. Including the wrong kind.

> Psuedocode is below:
>
> save(void *x, len)
> {
> //assume, memory, etc. is allocated.
> memcpy(generic_data_struct->data, data, len);
> }
>
> User code:
>
> struct a temp;
> save(&temp, sizeof(temp));

That won't help anyone - there is nowhere to store the data.

>
>> Of course you can make generic containers in C, but you cannot approach
>> the user convenience, safety, or efficiency that is found in other
>> languages that have better support for this kind of thing. You have no
>> choice but to use generic "void *" pointers, long names, and awkward syntax.
>
> I am not trying to do all those - safety, or efficiency, etc. I am just implementing them because I want to do this in my free time. And, in case, someone uses my code then it will be a bonus.
>

Doing things for fun and interest is always a good enough reason in my
book. But you should be aware of what you are doing, and what you are
not doing!

And if you /want/ other people to use your code (it's a great way to get
feedback with bug reports or suggestions), you will want to:

a) Use size_t like the rest of the world.

b) Stop making impossible claims about it and its usability.

c) Read the feedback and responses you get from discussions, with the
understanding that people are giving you free advice to help you write
better code.

> Why would the syntax be awkward? It is straight forward C syntax.
>

You didn't read my post, did you? Try it again - there's little point
in my repeating myself.

> The following lines of code don't look awkward to me:
>
> memcpy(generic_data_struct->data, data, len);
> save(&temp, sizeof(temp));
>
> Amit

Re: Why is glibc not extensive?

<c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:5245:0:b0:3a5:3623:3714 with SMTP id y5-20020ac85245000000b003a536233714mr6398477qtn.337.1668775654537;
Fri, 18 Nov 2022 04:47:34 -0800 (PST)
X-Received: by 2002:a0c:9061:0:b0:4bb:70e9:7372 with SMTP id
o88-20020a0c9061000000b004bb70e97372mr6433953qvo.30.1668775654352; Fri, 18
Nov 2022 04:47:34 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 18 Nov 2022 04:47:34 -0800 (PST)
In-Reply-To: <tl7sm7$2uat7$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=103.55.96.98; posting-account=VlS9cQoAAAAdP9kc5s4uYeJeZh3syM8E
NNTP-Posting-Host: 103.55.96.98
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org> <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me> <81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
<tl7sm7$2uat7$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
Subject: Re: Why is glibc not extensive?
From: amit2342...@gmail.com (A)
Injection-Date: Fri, 18 Nov 2022 12:47:34 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3569
 by: A - Fri, 18 Nov 2022 12:47 UTC

On Friday, 18 November 2022 at 17:39:58 UTC+5:30, David Brown wrote:
> On 18/11/2022 11:32, A wrote:
> >
> > On Friday, 18 November 2022 at 14:03:00 UTC+5:30, David Brown wrote:
> >> On 17/11/2022 14:18, A wrote:
> >>> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
> >>>> On 17/11/2022 06:31, Amit wrote:
> >>>>

> a) Use size_t like the rest of the world.
>

This is a problem. If I am not convinced then why should I follow the world? The world can use size_t but I will use long and if the world says that I should be using size_t then I will ignore that. And if because of this, no one wants to use my code then its fine with me. I am writing this code for myself, not for the world, and if someone wants to use it, its fine. If no one uses it then that is also fine with me.

But in my company, I definitely follow company's coding guidelines.

But for my personal software, I follow my coding guidelines even if it is different from the world. I am not forcing anyone to use my software. Its all free will.

About reading your post, I did read your post. It looks like you are referring to the following code of yours:

----------------
Then you have user convenience. If you want to set the field "x" in
element "i" of vector "v" to 1, in C++ you write "v[i].x = 1;". In C
"generic containers", you write:

widget * p;
vector_get_as_reference(v, i, &p);
p->x = 1;

Or maybe you have something with macro wrappers :

VECTOR_GET_AS_REF(v, i, widget)->x = 1;
----------------

Here, the point is that the data is opaque to my library. My library doesn't know what's there in the data. So, my library can't modify the data.

The user only knows what's there in the data. So, my library code won't be awkward.

My structure is:

struct element
{ void *data;
long data_len;
struct element *next;
};

And if user has stored widget * in data then the user can do:

elem = get_element(i);
((widget *)(elem->data))->x = 1.

The user code also doesn't look awkward to me but I am not sure but even if it is then should I (as a library developer) be bothered about that?

Amit

Re: Why is glibc not extensive?

<tl7viu$2ui7o$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Fri, 18 Nov 2022 13:59:09 +0100
Organization: A noiseless patient Spider
Lines: 81
Message-ID: <tl7viu$2ui7o$1@dont-email.me>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org>
<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me>
<81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
<tl7sm7$2uat7$1@dont-email.me>
<c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Nov 2022 12:59:10 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="af11441be165e54e49ca43a3f5870de0";
logging-data="3098872"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19F24wd7WdXs5eQ46VY5u9zh2jGYbdVr/k="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:3LLG3snB4Kp31jMwatE38gGJ51o=
In-Reply-To: <c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Fri, 18 Nov 2022 12:59 UTC

On 18/11/2022 13:47, A wrote:
> On Friday, 18 November 2022 at 17:39:58 UTC+5:30, David Brown wrote:
>> On 18/11/2022 11:32, A wrote:
>>>
>>> On Friday, 18 November 2022 at 14:03:00 UTC+5:30, David Brown wrote:
>>>> On 17/11/2022 14:18, A wrote:
>>>>> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
>>>>>> On 17/11/2022 06:31, Amit wrote:
>>>>>>
>
>
>> a) Use size_t like the rest of the world.
>>
>
> This is a problem. If I am not convinced then why should I follow the world? The world can use size_t but I will use long and if the world says that I should be using size_t then I will ignore that. And if because of this, no one wants to use my code then its fine with me. I am writing this code for myself, not for the world, and if someone wants to use it, its fine. If no one uses it then that is also fine with me.
>
> But in my company, I definitely follow company's coding guidelines.
>
> But for my personal software, I follow my coding guidelines even if it is different from the world. I am not forcing anyone to use my software. Its all free will.
>

You can write any kind of code for yourself - that's fine, of course.
But it seems a strange point to battle the world about.

> About reading your post, I did read your post. It looks like you are referring to the following code of yours:
>
> ----------------
> Then you have user convenience. If you want to set the field "x" in
> element "i" of vector "v" to 1, in C++ you write "v[i].x = 1;". In C
> "generic containers", you write:
>
> widget * p;
> vector_get_as_reference(v, i, &p);
> p->x = 1;
>
> Or maybe you have something with macro wrappers :
>
> VECTOR_GET_AS_REF(v, i, widget)->x = 1;
> ----------------
>
> Here, the point is that the data is opaque to my library. My library doesn't know what's there in the data. So, my library can't modify the data.
>
> The user only knows what's there in the data. So, my library code won't be awkward.
>
> My structure is:
>
> struct element
> {
> void *data;
> long data_len;
> struct element *next;
> };
>
> And if user has stored widget * in data then the user can do:
>
> elem = get_element(i);
> ((widget *)(elem->data))->x = 1.
>
> The user code also doesn't look awkward to me but I am not sure but even if it is then should I (as a library developer) be bothered about that?
>
> Amit

Again, you are missing any way of identifying which container is in use.
Surely your code supports more than one container in a program?

So the user code in your setup (for element "i" in vector "v") would be
something like :

struct element * elem = get_element(v, i)
((widget *)(elem->data))->x = 1

And you don't think that is awkward compared to :

v[i].x = 1;

?

Re: Why is glibc not extensive?

<f5eb8845-58bd-4aa6-96d9-f9b1c0bde26dn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:1093:0:b0:39c:df33:c189 with SMTP id a19-20020ac81093000000b0039cdf33c189mr6603362qtj.498.1668778039524;
Fri, 18 Nov 2022 05:27:19 -0800 (PST)
X-Received: by 2002:a37:854:0:b0:6fa:bb6:3492 with SMTP id 81-20020a370854000000b006fa0bb63492mr5822806qki.14.1668778039350;
Fri, 18 Nov 2022 05:27:19 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 18 Nov 2022 05:27:19 -0800 (PST)
In-Reply-To: <tl7viu$2ui7o$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=103.55.96.98; posting-account=VlS9cQoAAAAdP9kc5s4uYeJeZh3syM8E
NNTP-Posting-Host: 103.55.96.98
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org> <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me> <81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
<tl7sm7$2uat7$1@dont-email.me> <c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
<tl7viu$2ui7o$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f5eb8845-58bd-4aa6-96d9-f9b1c0bde26dn@googlegroups.com>
Subject: Re: Why is glibc not extensive?
From: amit2342...@gmail.com (A)
Injection-Date: Fri, 18 Nov 2022 13:27:19 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4029
 by: A - Fri, 18 Nov 2022 13:27 UTC

On Friday, 18 November 2022 at 18:29:24 UTC+5:30, David Brown wrote:
> On 18/11/2022 13:47, A wrote:
> > On Friday, 18 November 2022 at 17:39:58 UTC+5:30, David Brown wrote:
> >> On 18/11/2022 11:32, A wrote:
> >>>
> >>> On Friday, 18 November 2022 at 14:03:00 UTC+5:30, David Brown wrote:
> >>>> On 17/11/2022 14:18, A wrote:
> >>>>> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
> >>>>>> On 17/11/2022 06:31, Amit wrote:
> >>>>>>
> >
> >
> >> a) Use size_t like the rest of the world.
> >>
> >
> > This is a problem. If I am not convinced then why should I follow the world? The world can use size_t but I will use long and if the world says that I should be using size_t then I will ignore that. And if because of this, no one wants to use my code then its fine with me. I am writing this code for myself, not for the world, and if someone wants to use it, its fine. If no one uses it then that is also fine with me.
> >
> > But in my company, I definitely follow company's coding guidelines.
> >
> > But for my personal software, I follow my coding guidelines even if it is different from the world. I am not forcing anyone to use my software. Its all free will.
> >
> You can write any kind of code for yourself - that's fine, of course.
> But it seems a strange point to battle the world about.

I was only trying to check whether the world would agree with me. The world didn't agree with me and it is fine.

> Again, you are missing any way of identifying which container is in use.
> Surely your code supports more than one container in a program?
>

My library supports only one container. I have different libraries for different containers. Generic set is a library, then generic map is another different library, and so on.
> So the user code in your setup (for element "i" in vector "v") would be
> something like :
>
> struct element * elem = get_element(v, i)
> ((widget *)(elem->data))->x = 1
> And you don't think that is awkward compared to :
> v[i].x = 1;
> ?

In comparison, it definitely looks awkward.

But as standalone, the above C code doesn't look awkward to me - in the companies that I have worked for, I had to do far more awkward things in C than this. One example was to convert raw bytes into nested structures of a 3G telecommunications networking protocol way back in 2000 - 2001 for Lucent.

I think you must also would have written lot of awkward code in C.

Amit

Re: Why is glibc not extensive?

<tl8du1$k87$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!aioe.org!uabYU4OOdxBKlV2hpj27FQ.user.46.165.242.75.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Fri, 18 Nov 2022 17:04:01 +0000
Organization: Aioe.org NNTP Server
Message-ID: <tl8du1$k87$1@gioia.aioe.org>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org>
<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me>
<81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
<tl7sm7$2uat7$1@dont-email.me>
<c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="20743"; posting-host="uabYU4OOdxBKlV2hpj27FQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.5.0
X-Notice: Filtered by postfilter v. 0.9.2
 by: Bart - Fri, 18 Nov 2022 17:04 UTC

On 18/11/2022 12:47, A wrote:
> On Friday, 18 November 2022 at 17:39:58 UTC+5:30, David Brown wrote:
>> On 18/11/2022 11:32, A wrote:
>>>
>>> On Friday, 18 November 2022 at 14:03:00 UTC+5:30, David Brown wrote:
>>>> On 17/11/2022 14:18, A wrote:
>>>>> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
>>>>>> On 17/11/2022 06:31, Amit wrote:
>>>>>>
>
>
>> a) Use size_t like the rest of the world.
>>
>
> This is a problem. If I am not convinced then why should I follow the world? The world can use size_t but I will use long and if the world says that I should be using size_t then I will ignore that.

I use neither long nor size_t when calling `malloc`.

Because I normally use it via an FFI from other languages. The only
thing I need to know is that its parameter is a 64-bit unsigned type on
my platforms of interest.

I write that as 'u64', which is an exactly defined type in the language
I use.

The problem with `long` in C is that the language only specifies that it
is a signed type of at least 32 bits. It's actual size depends on platform.

So I'd stay clear of it. If I was using C to call malloc, I'd define
'u64' on top of `unsigned long long`, or on top of `uint64_t`, which I
know will be that size for all platforms of interest.

Re: Why is glibc not extensive?

<tlfajl$3ov81$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Mon, 21 Nov 2022 08:50:12 +0100
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <tlfajl$3ov81$1@dont-email.me>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org>
<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me>
<81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
<tl7sm7$2uat7$1@dont-email.me>
<c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
<tl8du1$k87$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 21 Nov 2022 07:50:13 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ddb0d85423665bc01be4416d93681612";
logging-data="3964161"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SnNlnjvljETYwZGMW/GWszjsG4Z/01Yc="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:PoxwCA47v6WryNy3IahERFt5CKE=
Content-Language: en-GB
In-Reply-To: <tl8du1$k87$1@gioia.aioe.org>
 by: David Brown - Mon, 21 Nov 2022 07:50 UTC

On 18/11/2022 18:04, Bart wrote:
> On 18/11/2022 12:47, A wrote:
>> On Friday, 18 November 2022 at 17:39:58 UTC+5:30, David Brown wrote:
>>> On 18/11/2022 11:32, A wrote:
>>>>
>>>> On Friday, 18 November 2022 at 14:03:00 UTC+5:30, David Brown wrote:
>>>>> On 17/11/2022 14:18, A wrote:
>>>>>> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
>>>>>>> On 17/11/2022 06:31, Amit wrote:
>>>>>>>
>>
>>
>>> a) Use size_t like the rest of the world.
>>>
>>
>> This is a problem. If I am not convinced then why should I follow the
>> world? The world can use size_t but I will use long and if the world
>> says that I should be using size_t then I will ignore that.
>
> I use neither long nor size_t when calling `malloc`.
>
> Because I normally use it via an FFI from other languages. The only
> thing I need to know is that its parameter is a 64-bit unsigned type on
> my platforms of interest.
>
> I write that as 'u64', which is an exactly defined type in the language
> I use.
>
> The problem with `long` in C is that the language only specifies that it
> is a signed type of at least 32 bits. It's actual size depends on platform.
>
> So I'd stay clear of it. If I was using C to call malloc, I'd define
> 'u64' on top of `unsigned long long`, or on top of `uint64_t`, which I
> know will be that size for all platforms of interest.
>

I appreciate preferring to use explicitly sized types. And I appreciate
preferring them over types whose size may vary between platforms, even
on the same target processor, such as "long".

But unless you have decided that the only platforms that are of interest
to you are those with 64-bit size_t, then calling malloc with a
parameter of type u64 (or "uint64_t", as we say in C), will be wrong on
other targets.

Maybe you no longer care about targets other than 64-bit PCs. And I
have no idea what the OP is targeting.

Bart (Was: Why is glibc not extensive?)

<tlg13v$ap3g$1@news.xmission.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c
Subject: Bart (Was: Why is glibc not extensive?)
Date: Mon, 21 Nov 2022 14:14:23 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tlg13v$ap3g$1@news.xmission.com>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com> <c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com> <tl8du1$k87$1@gioia.aioe.org> <tlfajl$3ov81$1@dont-email.me>
Injection-Date: Mon, 21 Nov 2022 14:14:23 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="353392"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 21 Nov 2022 14:14 UTC

In article <tlfajl$3ov81$1@dont-email.me>,
David Brown <david.brown@hesbynett.no> wrote:
....
>But unless you have decided that the only platforms that are of interest
>to you are those with 64-bit size_t, then calling malloc with a
>parameter of type u64 (or "uint64_t", as we say in C), will be wrong on
>other targets.
>
>Maybe you no longer care about targets other than 64-bit PCs. And I
>have no idea what the OP is targeting.

Bart has certainly made it clear in multiple postings to this newsgroup
that the only platform he cares about is 64-bit PCs. So, no ifs, buts or
maybes about that.

So, your implicit criticism of that position rings hollow.

--
If you don't have faith, it's because you are reading the Bible with an
honest, truthful, real-answer seeking heart.

- Rick C Hodgin -

Re: Why is glibc not extensive?

<a81ebdfc-4087-496a-9b21-3e321e37156an@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:1905:b0:6fa:6636:a7b0 with SMTP id bj5-20020a05620a190500b006fa6636a7b0mr47649qkb.55.1669047018635;
Mon, 21 Nov 2022 08:10:18 -0800 (PST)
X-Received: by 2002:a37:e210:0:b0:6d9:91ee:3db5 with SMTP id
g16-20020a37e210000000b006d991ee3db5mr6641907qki.614.1669047018373; Mon, 21
Nov 2022 08:10:18 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 21 Nov 2022 08:10:18 -0800 (PST)
In-Reply-To: <c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org> <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me> <81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
<tl7sm7$2uat7$1@dont-email.me> <c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a81ebdfc-4087-496a-9b21-3e321e37156an@googlegroups.com>
Subject: Re: Why is glibc not extensive?
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 21 Nov 2022 16:10:18 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2795
 by: Michael S - Mon, 21 Nov 2022 16:10 UTC

On Friday, November 18, 2022 at 2:47:42 PM UTC+2, A wrote:
> On Friday, 18 November 2022 at 17:39:58 UTC+5:30, David Brown wrote:
> > On 18/11/2022 11:32, A wrote:
> > >
> > > On Friday, 18 November 2022 at 14:03:00 UTC+5:30, David Brown wrote:
> > >> On 17/11/2022 14:18, A wrote:
> > >>> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
> > >>>> On 17/11/2022 06:31, Amit wrote:
> > >>>>
>
>
> > a) Use size_t like the rest of the world.
> >
> This is a problem. If I am not convinced then why should I follow the world? The world can use size_t but I will use long and if the world says that I should be using size_t then I will ignore that.

So, you don't want to use size_t because it is unsigned. Well.
Then use signed type ptrdiff_t. When you want to hold size of
arbitrary objects ptrdiff_t is more portable than 'long'.
In corner case of size of object that occupies more than half
of address space both ptrdiff_t and 'long' are not good enough,
but at least ptrdiff_t works in all other cases. The same can't
be said about 'long' which does not work in pretty common case
of size of big objects (>= 2GB) on Win64.

There is also non-C-standard signed type ssize_t that is
visually more similar to size_t and available pretty widely.
But I see no reasons to prefer it over ptrdiff_t.
Also, in my book visual similarity is a disadvantage.

Re: Why is glibc not extensive?

<tlltqr$ee1c$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Wed, 23 Nov 2022 13:55:06 -0600
Organization: A noiseless patient Spider
Lines: 120
Message-ID: <tlltqr$ee1c$1@dont-email.me>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5t5c$2mnpk$1@dont-email.me> <tl7eiv$6jrs$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 23 Nov 2022 19:55:07 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="e0bef838417651ee0e39dc2da450cf39";
logging-data="473132"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lZ1r4pI2lTHNkagbDNtKW"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.2
Cancel-Lock: sha1:ATyB3BaLbopSEG1bGwlO5NfXSNk=
In-Reply-To: <tl7eiv$6jrs$1@news.xmission.com>
Content-Language: en-US
 by: BGB - Wed, 23 Nov 2022 19:55 UTC

On 11/18/2022 2:09 AM, Kenny McCormack wrote:
> In article <tl5t5c$2mnpk$1@dont-email.me>,
> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 17.11.2022 um 07:31 schrieb Amit:
>>> Hi,
>>>
>>> In my opinion, glibc should have support for maps, sets, balanced
>>> binary trees, many more string functions, etc. (I know tree and hash
>>> are there in glibc), so that developers don't have to implement them
>>> themselves, thus saving lots of man hours all over the world. This
>>> will also make C more user friendly like C++ and Java.
>>>
>>> Amit
>>
>> glibc is for everything the C language supports as well as
>> Posix- SysV-,BSD- and Linux-spefic APIs. As C doesn't support
>> anything you suggest your idea doesn't fit.
>>
>
> I heard about this time, back in 1993 or thereabouts, where someone made a
> Usenet suggestion that something should be added to the existing libraries
> in either C or Unix (not sure which, it was a long time ago) and at least
> one responder *didn't* crap all over the idea.
>
> Hasn't happened since, of course...
>

Though to be fair, most stuff that makes sense in the C library is stuff
that is either relevant to the core language, or can't be done in a
portable or efficient way in C.

High-level features, like container libraries or data structures, do not
fit. These are better left to platform or 3rd party libraries.

As noted in the past, my ideas would include:
Ability to load/store values from a pointer with a specific size and
endianess;
Some extensions for malloc;
Some alternate memcpy variants with different semantics;
....

But could go further:
Some standardized-ish API for working with SIMD vectors.

As-is, this is a mix of implementation dependent and/or platform
dependent extensions. Ideally, it should also work independently of
if/what specific SIMD features are supported by the CPU (able to fall
back to a plain C implementation for targets) which lack native SIMD.

In my implementation, there are features which would not make as much
sense in C proper, such as extensions for a dynamic type system (my
compiler and ISA also partly get involved in the mechanics of the
dynamic type-system; which are also defined as part of the ABI rules).

Basically, it allows a "variant" type which may hold any type of value
as a tagged reference (or occasionally "boxing" values as heap-allocated
objects if they can't be held directly in the tagged-reference format).

This was relevant mostly to some of my other languages, and is also
seemingly coming up in the context of communication between tasks.

Say: Task A exists in one address space, Task B exists in another, and
one wants to pass some data from one to another.

If A malloc's something, and passes it to B, then B can't do anything
with it. A traditional approach would involve RPC and an IDL compiler
which has enough context to serialize and pass the data structures (say
via ASN.1 or whatever else).

But, with a dynamic type-system, it can be serialized and decoded
transparently without needing an IDL (and things like object-level
interfaces can be maintained transparently across task boundaries; the
underlying RPC events being mostly hidden from both parties).

Similarly, a more specialized mechanisms can be used for dealing with
buffer-like objects (say, a blob of bytes for IO, the contents of a "DIB
Bitmap Object", ...). (Say, the sending task registers the buffer as
"shared" and the receiving task "maps" the buffer via a syscall, which
then then performs a Task-to-Task memory copy if "read" or "dirty", and
when the buffer is released its contents are copied back to the original
buffer if it was mapped as "dirty" or "write"; the buffer typically
being "unshared" once the original call finishes).

This would then be wrapped in a more traditional C style interface.
Seemed like a "lesser evil" vs needing to deal with IDLs.

Note that local communication would use a bulky (but fast) serialization
scheme (mostly passing data as a blob of tagrefs with pointers replaced
with internal references into this blob). For "more general" use, would
likely use something akin to S-Expressions (the dynamic typesystem in
this case is along vaguely similar lines to those seen in Scheme and
Common Lisp), just printing and parsing S-Expressions would be too much
overhead for local communication between tasks.
An intermediate option being a more compact variable-length binary
serialization (say, not always burning 8 bytes for every fixnum, etc).

Such as a program talking to a GUI or Display HAL interface; used so
that it can draw contents to the screen without needing direct access to
the display hardware's framebuffer or similar. Where, in this case, this
was used rather than sockets (or the X11 protocol or similar). Seems
also like sockets would have had a higher overhead and latency in this
case than an RPC style mechanism (which in this case, more directly
invokes the task-switch mechanism; as a special type of syscall).

Interfaces across this mechanism can also take a form resembling COM
objects (but, a lot of the above comes up with "how does one pass data
beyond the basic argument list?"...).

But, yeah, not really sure what to make of this.
Makes some sense as platform level features, but not really as part of C
itself.

Re: Why is glibc not extensive?

<tlm29b$ee1c$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Wed, 23 Nov 2022 15:11:06 -0600
Organization: A noiseless patient Spider
Lines: 178
Message-ID: <tlm29b$ee1c$2@dont-email.me>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org>
<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 23 Nov 2022 21:11:07 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="e0bef838417651ee0e39dc2da450cf39";
logging-data="473132"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18B6m6Ls8NygG18zz+p35K/"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.2
Cancel-Lock: sha1:pEWq/USz1MZUX+UKnMx4/bQ2cZI=
Content-Language: en-US
In-Reply-To: <tl7fve$2tbg8$1@dont-email.me>
 by: BGB - Wed, 23 Nov 2022 21:11 UTC

On 11/18/2022 2:32 AM, David Brown wrote:
> On 17/11/2022 14:18, A wrote:
>> On Thursday, 17 November 2022 at 18:35:22 UTC+5:30, Bart wrote:
>>> On 17/11/2022 06:31, Amit wrote:
>>>
>>> Anyway a lot of your suggestions really demand generic solutions, and C
>>> doesn't have generic types. For those, there are myriad more assorted
>>> ways to add those to C, but the results are usually ungainly and painful
>>> to use.
>>>
>>> C is just not suited for such things.
>>
>> Generics can be implemented in C without much hassle.
>>
>
> No, they cannot.
>

IMHO, one may eventually reach a point where it becomes "less of a
hassle" to use an API wrapper to implement dynamic types, say for
example, one has types like:
lvoVariant //can hold "whatever"

Then say, calls like:
lvoVariant lvoFixnum(int64_t val); //wrap as a fixnum
int64_t lvoGetFixnum(lvoVariant var); //get the fixnum
bool lvoFixnumP(lvoVariant var); //is this a fixnum?

lvoVariant lvoFlonum(double val); //wrap as a flonum
double lvoGetFlonum(lvoVariant var); //get the flonum
bool lvoFlonumP(lvoVariant var); //is this a flonum?

...

For arrays:
lvoVariant lvoGetIndex(lvoVariant obj, int idx);
int lvoSetIndex(lvoVariant obj, int idx, lvoVariant var);
...

For cons lists:
lvoVariant lvoCons(lvoVariant car, lvoVariant cdr); //make a cons
bool lvoConsP(lvoVariant var); //is this a cons?
lvoVariant lvoCar(lvoVariant); //get 'car' from cons
lvoVariant lvoCdr(lvoVariant); //get 'cdr' from cons
...

For other stuff:
lvoVariant lvoAdd(lvoVariant va, lvoVariant vb); //add two values
...

So, for your "generic" array or dictionary, one can basically just put
whatever into it, and it "magically works", as the containers don't
actually need to care what types they are being used to hold.

Granted, yes, this sort of thing is very awkward and slow vs normal C
style, but can scale better to more complex cases than trying to pretend
that C is C++ ...

No good way to do automatic GC or "destructors" in pure C, this would
effectively require wrapper calls to initialize and destroy every local
variable, wrappers to manage things like variable assignment, ...

Say (as macros):
lvoInit(varA); //create and initialize a variable to null
lvoDestroy(varA); //destroy variable when it leaves scope
lvoSet(varA, value); //modify a variable

This crosses the line though in terms of how much hassle one can
reasonably expect people to deal with.

Say:
lvoInit2(varA, varB);
lvoSet(varB, lvoFixnum(3));
lvoSet(varA, lvoAdd(varB, lvoFixnum(4)));
...
lvoDestroy2(varA, varB);

Slightly less of a pain if one can have compiler extensions though:
__var varA, varB; //"__var" keyword invokes magic
varA=3;
varB=varA+4;

Where the compiler can manage most of the "arcane magic" (so, no need to
'init', 'set' or 'destroy' variables as the compiler can figure out this
part).

But, alas, this will not work in a compiler that does not support
dynamic types, whereas an API like the above doesn't need to assume any
special compiler support.

Overall performance impact would be similar in both cases (just because
they are less visible, doesn't mean that the code isn't being
implemented internally in terms of a mess of function calls into the
runtime library and similar).

Similarly, it is still kinda awkward to use given the typesystems don't
mix particularly cleanly (no good way around this).

Though, can note that, even as such, at least in my case, the relative
performance overhead of using the dynamic typesystem tends to be "less
severe than one might intuitively expect".

....

>> I am currently implementing C++ STL in C. And the my data structures
>> are generic - any type of data can be used just like in C++ STL.
>>
>
> No, they cannot.
>
> Of course you can make generic containers in C, but you cannot approach
> the user convenience, safety, or efficiency that is found in other
> languages that have better support for this kind of thing.  You have no
> choice but to use generic "void *" pointers, long names, and awkward
> syntax.
>
> If you have a vector of "widgets" in a programming language, and you try
> to add a "whatsit" to it, there are basically three things that can
> happen :
>
> 1. The compiler will complain (that's the C++ style).
>
> 2. The language can happily work correctly with a vector containing
> "widgets" and "whatsits" and treat them safely (even if the application
> code gets confused).  That's Python style.
>
> 3. The language can happily accept the nonsense at compile time, perhaps
> copying only bits of the "whatsit" or including rubbish in the vector.
> No one knows what will happen, and as you try to use the "whatsit" as
> though it were a "widget", you can cause all kinds of corruption or
> problems that turn up as unexpected effects in completely different
> parts of the code making debugging a nightmare.  That's C "void*" style.
>
>
> Then you have user convenience.  If you want to set the field "x" in
> element "i" of vector "v" to 1, in C++ you write "v[i].x = 1;".  In C
> "generic containers", you write:
>
>     widget * p;
>     vector_get_as_reference(v, i, &p);
>     p->x = 1;
>
> Or maybe you have something with macro wrappers :
>
>     VECTOR_GET_AS_REF(v, i, widget)->x = 1;
>
>
> I haven't even covered whether you should be holding copies of the
> widget structures in the vector, or references to them, or references
> with reference counters, or how you might handle allocation of new
> widgets and freeing of old ones.
>
> You /can/ do it all in C, but the usage of the containers will not be
> comparable in terms of convenience for the programmer, safety, or
> efficiency.
>
> The norm in C is to make the lists or containers you need for the data
> types you need and the features you need.  Usually that's not too hard,
> and the results are hugely nicer to use and more efficient than any C
> generic containers.
>
>
> That doesn't mean generic containers in C are a bad idea - especially
> more advanced containers that are harder for programmers to write
> themselves.  But don't kid yourself that you'll get something as nice as
> C++'s standard containers, or the containers built into most higher
> level languages.

Re: Why is glibc not extensive?

<867czh8x01.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Sat, 26 Nov 2022 09:07:58 -0800
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <867czh8x01.fsf@linuxsc.com>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com> <tl5bi5$laf$1@gioia.aioe.org> <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com> <tl7fve$2tbg8$1@dont-email.me> <81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com> <tl7sm7$2uat7$1@dont-email.me> <c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com> <a81ebdfc-4087-496a-9b21-3e321e37156an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader01.eternal-september.org; posting-host="65972d10173aaa2bd10990f397dff173";
logging-data="1506324"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+41FUxK57Ir5EFl77ic7tHnmyZi/+Kawc="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:g7A722nCV4DgWGKBWCew/Hb4LeI=
sha1:bPYk3niamxl6h4fHDSLkjbQEi04=
 by: Tim Rentsch - Sat, 26 Nov 2022 17:07 UTC

Michael S <already5chosen@yahoo.com> writes:

> On Friday, November 18, 2022 at 2:47:42 PM UTC+2, A wrote:
>
>> On Friday, 18 November 2022 at 17:39:58 UTC+5:30, David Brown wrote:

[...]

>>> a) Use size_t like the rest of the world.
>>
>> This is a problem. If I am not convinced then why should I follow
>> the world? The world can use size_t but I will use long and if the
>> world says that I should be using size_t then I will ignore that.
>
> So, you don't want to use size_t because it is unsigned. Well.
> Then use signed type ptrdiff_t. When you want to hold size of
> arbitrary objects ptrdiff_t is more portable than 'long'.
> In corner case of size of object that occupies more than half
> of address space both ptrdiff_t and 'long' are not good enough,
> but at least ptrdiff_t works in all other cases. The same can't
> be said about 'long' which does not work in pretty common case
> of size of big objects (>= 2GB) on Win64.

IMO it's a mistake to hard-wire either 'long' or 'ptrdiff_t' to
be the name of a (signed) size type. Whatever type is chosen
should allow as wide a range of values as needed, and neither of
those types will necessarily do that. Furthermore the type name
used should reflect the purpose rather than the representation.
Assuming the name 's_size' is considered appropriate and
acceptable, a suitable typedef can be chosen using a scheme
along these lines:

#include <limits.h>
#include <stdint.h>

#if INT_MAX >= SIZE_MAX
typedef int s_size;
#elif LONG_MAX >= SIZE_MAX
typedef long s_size;
#elif defined LLONG_MAX && LLONG_MAX >= SIZE_MAX
typedef long long s_size;
#else
typedef intmax_t s_size;
#endif

after which any interfaces desired should use 's_size' for values
of a signed size type.

Re: Why is glibc not extensive?

<de182215-be2a-46c7-868e-7759bee60635n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:4d06:0:b0:3a5:95cc:70e2 with SMTP id w6-20020ac84d06000000b003a595cc70e2mr41790685qtv.293.1669507919939;
Sat, 26 Nov 2022 16:11:59 -0800 (PST)
X-Received: by 2002:ad4:53c5:0:b0:4c6:a267:69a6 with SMTP id
k5-20020ad453c5000000b004c6a26769a6mr24272025qvv.77.1669507919797; Sat, 26
Nov 2022 16:11:59 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 26 Nov 2022 16:11:59 -0800 (PST)
In-Reply-To: <867czh8x01.fsf@linuxsc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:8ca1:2642:c05a:88da;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:8ca1:2642:c05a:88da
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org> <62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me> <81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
<tl7sm7$2uat7$1@dont-email.me> <c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
<a81ebdfc-4087-496a-9b21-3e321e37156an@googlegroups.com> <867czh8x01.fsf@linuxsc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <de182215-be2a-46c7-868e-7759bee60635n@googlegroups.com>
Subject: Re: Why is glibc not extensive?
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 27 Nov 2022 00:11:59 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4376
 by: Michael S - Sun, 27 Nov 2022 00:11 UTC

On Saturday, November 26, 2022 at 7:08:15 PM UTC+2, Tim Rentsch wrote:
> Michael S <already...@yahoo.com> writes:
>
> > On Friday, November 18, 2022 at 2:47:42 PM UTC+2, A wrote:
> >
> >> On Friday, 18 November 2022 at 17:39:58 UTC+5:30, David Brown wrote:
> [...]
> >>> a) Use size_t like the rest of the world.
> >>
> >> This is a problem. If I am not convinced then why should I follow
> >> the world? The world can use size_t but I will use long and if the
> >> world says that I should be using size_t then I will ignore that.
> >
> > So, you don't want to use size_t because it is unsigned. Well.
> > Then use signed type ptrdiff_t. When you want to hold size of
> > arbitrary objects ptrdiff_t is more portable than 'long'.
> > In corner case of size of object that occupies more than half
> > of address space both ptrdiff_t and 'long' are not good enough,
> > but at least ptrdiff_t works in all other cases. The same can't
> > be said about 'long' which does not work in pretty common case
> > of size of big objects (>= 2GB) on Win64.
> IMO it's a mistake to hard-wire either 'long' or 'ptrdiff_t' to
> be the name of a (signed) size type. Whatever type is chosen
> should allow as wide a range of values as needed, and neither of
> those types will necessarily do that. Furthermore the type name
> used should reflect the purpose rather than the representation.
> Assuming the name 's_size' is considered appropriate and
> acceptable, a suitable typedef can be chosen using a scheme
> along these lines:
>
> #include <limits.h>
> #include <stdint.h>
>
> #if INT_MAX >= SIZE_MAX
> typedef int s_size;
> #elif LONG_MAX >= SIZE_MAX
> typedef long s_size;
> #elif defined LLONG_MAX && LLONG_MAX >= SIZE_MAX
> typedef long long s_size;
> #else
> typedef intmax_t s_size;
> #endif
>
> after which any interfaces desired should use 's_size' for values
> of a signed size type.

Your solution is theoretically pure but I don't find it practical.
For example, I don't want 64-bit s_size on my Cortex-M that
in practice will never ever have objects bigger than 2**31-1.

Also, hopefully before I am retired, intmax_t on common 64-bit
platforms (x86-64, ARM64, POWER) will become 128-bit.
In my personal opinion, it's long overdue.
If current rate of Moore Law is not improved then even with
all conservatism of standard bodies it will happen several
decades before the first individual object reaches 2**63-1.
Or, much more likely, on 64-bit architectures, size of
individual objects will never be as big as 2**63-1. If it at all
happens, it would be long after migration to wider addresses.
So, if we follow your suggestion, we'll use 128-bit s_size
on 64-bit platforms for sole benefit of compatibility with very
unlikely corner case in very remote future.

Re: Why is glibc not extensive?

<20221127045152.541@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Why is glibc not extensive?
Date: Sun, 27 Nov 2022 13:05:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20221127045152.541@kylheku.com>
References: <c8037c65-2272-4e73-abba-22c06d6f9a90n@googlegroups.com>
<tl5bi5$laf$1@gioia.aioe.org>
<62490c42-3d22-4386-ba2c-09aaf49eb1a5n@googlegroups.com>
<tl7fve$2tbg8$1@dont-email.me>
<81589145-5348-439c-87d7-e34b85378ae6n@googlegroups.com>
<tl7sm7$2uat7$1@dont-email.me>
<c9a90f81-5fa8-4157-8901-e7510da1019cn@googlegroups.com>
<a81ebdfc-4087-496a-9b21-3e321e37156an@googlegroups.com>
<867czh8x01.fsf@linuxsc.com>
<de182215-be2a-46c7-868e-7759bee60635n@googlegroups.com>
Injection-Date: Sun, 27 Nov 2022 13:05:18 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="0dc85c860ed2a9821c15c2e817433496";
logging-data="1770130"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gs+f9MFQrdhGo/x1d7ub5LHvdoiveuaE="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:y5w+jJdNe5riN5DKAR7q2DLh9Vw=
 by: Kaz Kylheku - Sun, 27 Nov 2022 13:05 UTC

On 2022-11-27, Michael S <already5chosen@yahoo.com> wrote:
> If current rate of Moore Law is not improved then even with
> all conservatism of standard bodies it will happen several
> decades before the first individual object reaches 2**63-1.

Currently, people are using the top bits of 64 bit pointers
for funny things:

- Android implements pointer-tagging. The upper 16 bits of a pointer
are a tag, which can be used to validate it. E.g. if you malloc
some space, free it and malloc again such that the same space
is returned, it will have a different tag. The hardware strips
away the tag; only the lower 48 bits (at most) is significant.

- A collection of techiques called NaN boxing can store a 50 bit
pointer, fully unboxed 64 bit double, or a 50 bit integer, in a 64 bit
word. This is a boon for dynamic languages, which can have unboxed
floats.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor