Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

He's dead, Jim.


devel / comp.lang.c / strings or enums?

SubjectAuthor
* strings or enums?Malcolm McLean
+* Re: strings or enums?fir
|`* Re: strings or enums?fir
| `- Re: strings or enums?fir
+* Re: strings or enums?Ben Bacarisse
|`* Re: strings or enums?Malcolm McLean
| +- Re: strings or enums?Richard Damon
| `* Re: strings or enums?Ben Bacarisse
|  `* Re: strings or enums?Malcolm McLean
|   `* Re: strings or enums?Ben Bacarisse
|    `- Re: strings or enums?Malcolm McLean
`* Re: strings or enums?David Brown
 +* Re: strings or enums?Paul N
 |`* Re: strings or enums?David Brown
 | `* Re: strings or enums?Blue-Maned_Hawk
 |  `- Re: strings or enums?David Brown
 +* Re: strings or enums?fir
 |`* Re: strings or enums?fir
 | `* Re: strings or enums?Malcolm McLean
 |  +* Re: strings or enums?fir
 |  |+* Re: strings or enums?Scott Lurndal
 |  ||+* Re: strings or enums?fir
 |  |||`- Re: strings or enums?fir
 |  ||`- Re: strings or enums?Malcolm McLean
 |  |`- Re: strings or enums?fir
 |  `* Re: strings or enums?David Brown
 |   `* Re: strings or enums?Malcolm McLean
 |    +* Re: strings or enums?fir
 |    |`- Re: strings or enums?fir
 |    `* Re: strings or enums?David Brown
 |     `* Re: strings or enums?Vir Campestris
 |      `- Re: strings or enums?Tim Rentsch
 `* Re: strings or enums?Malcolm McLean
  `- Re: strings or enums?David Brown

Pages:12
strings or enums?

<a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:46:b0:401:e2bb:e429 with SMTP id y6-20020a05622a004600b00401e2bbe429mr14707qtw.9.1690626039279;
Sat, 29 Jul 2023 03:20:39 -0700 (PDT)
X-Received: by 2002:a05:6808:d4b:b0:3a3:7719:b09a with SMTP id
w11-20020a0568080d4b00b003a37719b09amr9599678oik.4.1690626038986; Sat, 29 Jul
2023 03:20:38 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.1d4.us!usenet.blueworldhosting.com!diablo1.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: Sat, 29 Jul 2023 03:20:38 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:e8de:bdc2:dfd9:7264;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:e8de:bdc2:dfd9:7264
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
Subject: strings or enums?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sat, 29 Jul 2023 10:20:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2225
 by: Malcolm McLean - Sat, 29 Jul 2023 10:20 UTC

Do people prefer string or enum arguments to functions taking one of a restricted list of options?
The function I'm writing is

char *loadasutf8wthknownformat(const char *filename, format, int *error);

If format is an enum, I'd have to create an enum with a list of formats supported. If it's a string, the caller has to pass one of a restricted set of formats.

Advantages to the enum
It's a lot harder to pass a typo or an ill- formed format.
Caller has a list of allowed formats which automatically update.
It's more machine efficent (but won't matter for this function)

Advantages to the string
Several functions might operate on text file formats. Strings don't
pollute the namespace.
It's easier to print out a human-readable diagnostic at runtime.
It's slightly more natural if the origin of the value is an input string
anyway and not a hard-coded constant.
If an exponential combination problem starts, the string can solve it
by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
or "little-endian" . With enums you would have to double the length of the
list.

The hybrid compromise which we often use at work is to #define
string constants.

Re: strings or enums?

<a0663885-24c8-4961-b2e6-4ef3bead0e2dn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:2c85:0:b0:76a:de57:440b with SMTP id s127-20020a372c85000000b0076ade57440bmr14424qkh.7.1690638202215;
Sat, 29 Jul 2023 06:43:22 -0700 (PDT)
X-Received: by 2002:a05:6870:988c:b0:1bb:4593:edfb with SMTP id
eg12-20020a056870988c00b001bb4593edfbmr6108387oab.1.1690638201969; Sat, 29
Jul 2023 06:43:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.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: Sat, 29 Jul 2023 06:43:21 -0700 (PDT)
In-Reply-To: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.128; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.128
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a0663885-24c8-4961-b2e6-4ef3bead0e2dn@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Sat, 29 Jul 2023 13:43:22 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 42
 by: fir - Sat, 29 Jul 2023 13:43 UTC

sobota, 29 lipca 2023 o 12:20:47 UTC+2 Malcolm McLean napisał(a):
> Do people prefer string or enum arguments to functions taking one of a restricted list of options?
> The function I'm writing is
>
> char *loadasutf8wthknownformat(const char *filename, format, int *error);
>
> If format is an enum, I'd have to create an enum with a list of formats supported. If it's a string, the caller has to pass one of a restricted set of formats.
>
> Advantages to the enum
> It's a lot harder to pass a typo or an ill- formed format.
> Caller has a list of allowed formats which automatically update.
> It's more machine efficent (but won't matter for this function)
>
> Advantages to the string
> Several functions might operate on text file formats. Strings don't
> pollute the namespace.
> It's easier to print out a human-readable diagnostic at runtime.
> It's slightly more natural if the origin of the value is an input string
> anyway and not a hard-coded constant.
> If an exponential combination problem starts, the string can solve it
> by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
> or "little-endian" . With enums you would have to double the length of the
> list.
>
> The hybrid compromise which we often use at work is to #define
> string constants.

i use what i call signetuires (it is 'this like things')

its becouse probably the demon of coding i recently wrote about "distributed code"
i mean code you need to jump on many places when you write - this jumping kills productivity
- thus classical enums are last of use for me now (c lack ad hoc enums idea i mean anums that you write lik 'that' but that are mapped to integers or somethig liek that this way you can have milions of them and each one noc ocupy more than word of cpu

Re: strings or enums?

<65d458e0-1e10-4c7c-9973-c371e7afe1d2n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:55d0:0:b0:635:e19a:6cc4 with SMTP id bt16-20020ad455d0000000b00635e19a6cc4mr31097qvb.2.1690640494672;
Sat, 29 Jul 2023 07:21:34 -0700 (PDT)
X-Received: by 2002:a05:6808:1486:b0:3a2:ac4:88dd with SMTP id
e6-20020a056808148600b003a20ac488ddmr9948434oiw.4.1690640494426; Sat, 29 Jul
2023 07:21:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.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, 29 Jul 2023 07:21:33 -0700 (PDT)
In-Reply-To: <a0663885-24c8-4961-b2e6-4ef3bead0e2dn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.16; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.16
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com> <a0663885-24c8-4961-b2e6-4ef3bead0e2dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <65d458e0-1e10-4c7c-9973-c371e7afe1d2n@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Sat, 29 Jul 2023 14:21:34 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3403
 by: fir - Sat, 29 Jul 2023 14:21 UTC

sobota, 29 lipca 2023 o 15:43:30 UTC+2 fir napisał(a):
> sobota, 29 lipca 2023 o 12:20:47 UTC+2 Malcolm McLean napisał(a):
> > Do people prefer string or enum arguments to functions taking one of a restricted list of options?
> > The function I'm writing is
> >
> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> >
> > If format is an enum, I'd have to create an enum with a list of formats supported. If it's a string, the caller has to pass one of a restricted set of formats.
> >
> > Advantages to the enum
> > It's a lot harder to pass a typo or an ill- formed format.
> > Caller has a list of allowed formats which automatically update.
> > It's more machine efficent (but won't matter for this function)
> >
> > Advantages to the string
> > Several functions might operate on text file formats. Strings don't
> > pollute the namespace.
> > It's easier to print out a human-readable diagnostic at runtime.
> > It's slightly more natural if the origin of the value is an input string
> > anyway and not a hard-coded constant.
> > If an exponential combination problem starts, the string can solve it
> > by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
> > or "little-endian" . With enums you would have to double the length of the
> > list.
> >
> > The hybrid compromise which we often use at work is to #define
> > string constants.
> i use what i call signetuires (it is 'this like things')
>
> its becouse probably the demon of coding i recently wrote about "distributed code"
> i mean code you need to jump on many places when you write - this jumping kills productivity
> - thus classical enums are last of use for me now (c lack ad hoc enums idea i mean anums that you write lik 'that' but that are mapped to integers or somethig liek that this way you can have milions of them and each one noc ocupy more than word of cpu

probably one could even say that this code distribution (multiply of places) is dodays tiem goto/global variavles - code distribution is evil

Re: strings or enums?

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

  copy mid

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

  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: strings or enums?
Date: Sat, 29 Jul 2023 21:35:49 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <87jzuixxp6.fsf@bsb.me.uk>
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="7dc7094286c70ffc9164d202debea076";
logging-data="2851878"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UTx9eNdqU2CmhD+lgN/94Qx73vgN2ciY="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:PYYLenCnd0dfq8frL/jUL7hcyIw=
sha1:PTvAYStE8t8QK9gtFT5hJlCuBC0=
X-BSB-Auth: 1.1a07727f0ecf13ad6e18.20230729213549BST.87jzuixxp6.fsf@bsb.me.uk
 by: Ben Bacarisse - Sat, 29 Jul 2023 20:35 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> Do people prefer string or enum arguments to functions taking one of a
> restricted list of options? The function I'm writing is
>
> char *loadasutf8wthknownformat(const char *filename, format, int *error);
>
> If format is an enum, I'd have to create an enum with a list of
> formats supported. If it's a string, the caller has to pass one of a
> restricted set of formats.

I think I'd #define the formats (as you suggest later on).

> Advantages to the enum
> It's a lot harder to pass a typo or an ill- formed format.
> Caller has a list of allowed formats which automatically update.
> It's more machine efficent (but won't matter for this function)
>
> Advantages to the string
> Several functions might operate on text file formats. Strings don't
> pollute the namespace.
> It's easier to print out a human-readable diagnostic at runtime.
> It's slightly more natural if the origin of the value is an input string
> anyway and not a hard-coded constant.

When I first learned Lisp, I could not work out what symbols were
supposed to be. They were "things" whose only purposes appeared to be
to different from other symbols, but they all sorts of uses, and this is
one other them: they are intrinsically human-readable distinct values.

> If an exponential combination problem starts, the string can solve it
> by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
> or "little-endian" . With enums you would have to double the length of the
> list.
>
> The hybrid compromise which we often use at work is to #define
> string constants.

And you can combine them:

decode(filename, ENCODING_UTF_16 | ENCODING_BIG_ENDIAN);

--
Ben.

Re: strings or enums?

<416bc8c5-da52-4e46-a536-e678072a5147n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:4a43:b0:63c:fc43:fd51 with SMTP id ph3-20020a0562144a4300b0063cfc43fd51mr25423qvb.11.1690730884007;
Sun, 30 Jul 2023 08:28:04 -0700 (PDT)
X-Received: by 2002:a05:6830:114f:b0:6b8:6cec:b73e with SMTP id
x15-20020a056830114f00b006b86cecb73emr8834548otq.5.1690730883714; Sun, 30 Jul
2023 08:28:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 30 Jul 2023 08:28:03 -0700 (PDT)
In-Reply-To: <87jzuixxp6.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=81.143.231.9; posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 81.143.231.9
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com> <87jzuixxp6.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <416bc8c5-da52-4e46-a536-e678072a5147n@googlegroups.com>
Subject: Re: strings or enums?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sun, 30 Jul 2023 15:28:03 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Malcolm McLean - Sun, 30 Jul 2023 15:28 UTC

On Saturday, 29 July 2023 at 21:36:04 UTC+1, Ben Bacarisse wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>
> > Do people prefer string or enum arguments to functions taking one of a
> > restricted list of options? The function I'm writing is
> >
> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> >
> > If format is an enum, I'd have to create an enum with a list of
> > formats supported. If it's a string, the caller has to pass one of a
> > restricted set of formats.
> I think I'd #define the formats (as you suggest later on).
> > Advantages to the enum
> > It's a lot harder to pass a typo or an ill- formed format.
> > Caller has a list of allowed formats which automatically update.
> > It's more machine efficent (but won't matter for this function)
> >
> > Advantages to the string
> > Several functions might operate on text file formats. Strings don't
> > pollute the namespace.
> > It's easier to print out a human-readable diagnostic at runtime.
> > It's slightly more natural if the origin of the value is an input string
> > anyway and not a hard-coded constant.
> When I first learned Lisp, I could not work out what symbols were
> supposed to be. They were "things" whose only purposes appeared to be
> to different from other symbols, but they all sorts of uses, and this is
> one other them: they are intrinsically human-readable distinct values.
> > If an exponential combination problem starts, the string can solve it
> > by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
> > or "little-endian" . With enums you would have to double the length of the
> > list.
> >
> > The hybrid compromise which we often use at work is to #define
> > string constants.
> And you can combine them:
>
> decode(filename, ENCODING_UTF_16 | ENCODING_BIG_ENDIAN);
>
I've realised there's another flag. Sometimes the user will want to accept
UTF-16 with surrogate pairs, sometimes he'll want to reject it (because
his program can't handle the situation where one 16 bit value doesn't represent
one character). So the feared combinatorial explosion is starting.

Re: strings or enums?

<j4wxM.289872$AsA.163013@fx18.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx18.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: strings or enums?
Content-Language: en-US
Newsgroups: comp.lang.c
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<87jzuixxp6.fsf@bsb.me.uk>
<416bc8c5-da52-4e46-a536-e678072a5147n@googlegroups.com>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <416bc8c5-da52-4e46-a536-e678072a5147n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 16
Message-ID: <j4wxM.289872$AsA.163013@fx18.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 30 Jul 2023 12:19:27 -0400
X-Received-Bytes: 1556
 by: Richard Damon - Sun, 30 Jul 2023 16:19 UTC

On 7/30/23 11:28 AM, Malcolm McLean wrote:
> On Saturday, 29 July 2023 at 21:36:04 UTC+1, Ben Bacarisse wrote:
>> And you can combine them:
>>
>> decode(filename, ENCODING_UTF_16 | ENCODING_BIG_ENDIAN);
>>
> I've realised there's another flag. Sometimes the user will want to accept
> UTF-16 with surrogate pairs, sometimes he'll want to reject it (because
> his program can't handle the situation where one 16 bit value doesn't represent
> one character). So the feared combinatorial explosion is starting.

No, UTF-16 means you can have surrogate pairs representing the 21 bit
character.

If you don't want any values outside the 16 bit BMP, you want to use
UCS-2 not UTF-16

Re: strings or enums?

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

  copy mid

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

  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: strings or enums?
Date: Sun, 30 Jul 2023 18:09:42 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <87r0opwckp.fsf@bsb.me.uk>
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<87jzuixxp6.fsf@bsb.me.uk>
<416bc8c5-da52-4e46-a536-e678072a5147n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="45172263353cca8fddc559bb57fe6713";
logging-data="3144543"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/prLujYMK7beYkgw2seb1NvugTr7VMtJA="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:u666ncJyz1OiZm1+tzrtOxfE6D4=
sha1:rjCE3Sx+hcETsQHnk9O59JOmIGc=
X-BSB-Auth: 1.3c806f5f970d50ea22e0.20230730180942BST.87r0opwckp.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 30 Jul 2023 17:09 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Saturday, 29 July 2023 at 21:36:04 UTC+1, Ben Bacarisse wrote:
>> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>>
>> > Do people prefer string or enum arguments to functions taking one of a
>> > restricted list of options? The function I'm writing is
>> >
>> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
>> >
>> > If format is an enum, I'd have to create an enum with a list of
>> > formats supported. If it's a string, the caller has to pass one of a
>> > restricted set of formats.
>> I think I'd #define the formats (as you suggest later on).
>> > Advantages to the enum
>> > It's a lot harder to pass a typo or an ill- formed format.
>> > Caller has a list of allowed formats which automatically update.
>> > It's more machine efficent (but won't matter for this function)
>> >
>> > Advantages to the string
>> > Several functions might operate on text file formats. Strings don't
>> > pollute the namespace.
>> > It's easier to print out a human-readable diagnostic at runtime.
>> > It's slightly more natural if the origin of the value is an input string
>> > anyway and not a hard-coded constant.
>> When I first learned Lisp, I could not work out what symbols were
>> supposed to be. They were "things" whose only purposes appeared to be
>> to different from other symbols, but they all sorts of uses, and this is
>> one other them: they are intrinsically human-readable distinct values.
>> > If an exponential combination problem starts, the string can solve it
>> > by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
>> > or "little-endian" . With enums you would have to double the length of the
>> > list.
>> >
>> > The hybrid compromise which we often use at work is to #define
>> > string constants.
>> And you can combine them:
>>
>> decode(filename, ENCODING_UTF_16 | ENCODING_BIG_ENDIAN);
>>
> I've realised there's another flag. Sometimes the user will want to
> accept UTF-16 with surrogate pairs, sometimes he'll want to reject it
> (because his program can't handle the situation where one 16 bit value
> doesn't represent one character). So the feared combinatorial
> explosion is starting.

No, that's not a flag, that's another encoding altogether called UCS-16.
UTF-16 implies the use of surrogates.

--
Ben.

Re: strings or enums?

<5d37902b-3763-4321-9e24-abf8866662a2n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:18d4:b0:63d:2f29:5e32 with SMTP id cy20-20020a05621418d400b0063d2f295e32mr25204qvb.9.1690740020383;
Sun, 30 Jul 2023 11:00:20 -0700 (PDT)
X-Received: by 2002:a05:6870:c7a9:b0:1bb:715a:4b1f with SMTP id
dy41-20020a056870c7a900b001bb715a4b1fmr9190903oab.0.1690740020155; Sun, 30
Jul 2023 11:00:20 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 30 Jul 2023 11:00:19 -0700 (PDT)
In-Reply-To: <87r0opwckp.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:e8de:bdc2:dfd9:7264;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:e8de:bdc2:dfd9:7264
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<87jzuixxp6.fsf@bsb.me.uk> <416bc8c5-da52-4e46-a536-e678072a5147n@googlegroups.com>
<87r0opwckp.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5d37902b-3763-4321-9e24-abf8866662a2n@googlegroups.com>
Subject: Re: strings or enums?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sun, 30 Jul 2023 18:00:20 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Malcolm McLean - Sun, 30 Jul 2023 18:00 UTC

On Sunday, 30 July 2023 at 18:09:57 UTC+1, Ben Bacarisse wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>
> > On Saturday, 29 July 2023 at 21:36:04 UTC+1, Ben Bacarisse wrote:
> >> Malcolm McLean <malcolm.ar...@gmail.com> writes:
> >>
> >> > Do people prefer string or enum arguments to functions taking one of a
> >> > restricted list of options? The function I'm writing is
> >> >
> >> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> >> >
> >> > If format is an enum, I'd have to create an enum with a list of
> >> > formats supported. If it's a string, the caller has to pass one of a
> >> > restricted set of formats.
> >> I think I'd #define the formats (as you suggest later on).
> >> > Advantages to the enum
> >> > It's a lot harder to pass a typo or an ill- formed format.
> >> > Caller has a list of allowed formats which automatically update.
> >> > It's more machine efficent (but won't matter for this function)
> >> >
> >> > Advantages to the string
> >> > Several functions might operate on text file formats. Strings don't
> >> > pollute the namespace.
> >> > It's easier to print out a human-readable diagnostic at runtime.
> >> > It's slightly more natural if the origin of the value is an input string
> >> > anyway and not a hard-coded constant.
> >> When I first learned Lisp, I could not work out what symbols were
> >> supposed to be. They were "things" whose only purposes appeared to be
> >> to different from other symbols, but they all sorts of uses, and this is
> >> one other them: they are intrinsically human-readable distinct values.
> >> > If an exponential combination problem starts, the string can solve it
> >> > by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
> >> > or "little-endian" . With enums you would have to double the length of the
> >> > list.
> >> >
> >> > The hybrid compromise which we often use at work is to #define
> >> > string constants.
> >> And you can combine them:
> >>
> >> decode(filename, ENCODING_UTF_16 | ENCODING_BIG_ENDIAN);
> >>
> > I've realised there's another flag. Sometimes the user will want to
> > accept UTF-16 with surrogate pairs, sometimes he'll want to reject it
> > (because his program can't handle the situation where one 16 bit value
> > doesn't represent one character). So the feared combinatorial
> > explosion is starting.
> No, that's not a flag, that's another encoding altogether called UCS-16.
> UTF-16 implies the use of surrogates.
>
The Baby X resource compiler is primarily a utility to help build Baby X programs..
Baby X treats all string data as UTF-8, and if a string is passed to a non-UTF-8
compatible function then that should be considered a bug. So the utf16 tag
(input is in any text format, output is in UTF-16) doesn't really have a place in
Baby X programs.
However I decided to include it, somewhat reluctantly, to support non-Baby X
users of the resource compiler. But the only real reason for using UTF-16,
apart from the obvious one, which is to pass to third party libaries expecting
UTF-16, is to have "wide characters", where one "wide character" represents one
glyph. If you allow surrogate pairs, most of the advantges of UTF-16 over UTF-8
disappear.
So if someone uses the utf16 tag, they probably want to ensure that the data
contains no surrogate pairs. But not always.

The default behaviour of the Baby X resource compiler is to auto-detect the
format of text input files. However it's impossible to write an infallible detector.
So my current idea is to provide an optional attribute which gives the file format
and forces the system to load the data in that format. Adding surrogate pair
rejection to that format specification seems to be a simple way of achieving
utf16 tags free of surrogate pairs. There are also some near UTF-16 formats.
Which is one reason UTF-16 is undesireable. But you don't want to terrorise
the user. If it's 16 bit Unicode, then in most people's eyes, it's UTF-16.

Re: strings or enums?

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

  copy mid

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

  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: strings or enums?
Date: Sun, 30 Jul 2023 20:15:15 +0100
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <87leexw6rg.fsf@bsb.me.uk>
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<87jzuixxp6.fsf@bsb.me.uk>
<416bc8c5-da52-4e46-a536-e678072a5147n@googlegroups.com>
<87r0opwckp.fsf@bsb.me.uk>
<5d37902b-3763-4321-9e24-abf8866662a2n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="45172263353cca8fddc559bb57fe6713";
logging-data="3164646"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19js+P+alNmsiokpus5lZuO7dnRTSCAy0E="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:4D1NJSHKf7SrXjbZ1RWdyUTf2Rk=
sha1:BPpiAQafCJsY2+UlM45OgaPxyyY=
X-BSB-Auth: 1.5678fe34bca4e2a3f41a.20230730201515BST.87leexw6rg.fsf@bsb.me.uk
 by: Ben Bacarisse - Sun, 30 Jul 2023 19:15 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Sunday, 30 July 2023 at 18:09:57 UTC+1, Ben Bacarisse wrote:
>> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>>
>> > On Saturday, 29 July 2023 at 21:36:04 UTC+1, Ben Bacarisse wrote:
>> >> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>> >>
>> >> > Do people prefer string or enum arguments to functions taking one of a
>> >> > restricted list of options? The function I'm writing is
>> >> >
>> >> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
>> >> >
>> >> > If format is an enum, I'd have to create an enum with a list of
>> >> > formats supported. If it's a string, the caller has to pass one of a
>> >> > restricted set of formats.
>> >> I think I'd #define the formats (as you suggest later on).
>> >> > Advantages to the enum
>> >> > It's a lot harder to pass a typo or an ill- formed format.
>> >> > Caller has a list of allowed formats which automatically update.
>> >> > It's more machine efficent (but won't matter for this function)
>> >> >
>> >> > Advantages to the string
>> >> > Several functions might operate on text file formats. Strings don't
>> >> > pollute the namespace.
>> >> > It's easier to print out a human-readable diagnostic at runtime.
>> >> > It's slightly more natural if the origin of the value is an input string
>> >> > anyway and not a hard-coded constant.
>> >> When I first learned Lisp, I could not work out what symbols were
>> >> supposed to be. They were "things" whose only purposes appeared to be
>> >> to different from other symbols, but they all sorts of uses, and this is
>> >> one other them: they are intrinsically human-readable distinct values.
>> >> > If an exponential combination problem starts, the string can solve it
>> >> > by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
>> >> > or "little-endian" . With enums you would have to double the length of the
>> >> > list.
>> >> >
>> >> > The hybrid compromise which we often use at work is to #define
>> >> > string constants.
>> >> And you can combine them:
>> >>
>> >> decode(filename, ENCODING_UTF_16 | ENCODING_BIG_ENDIAN);
>> >>
>> > I've realised there's another flag. Sometimes the user will want to
>> > accept UTF-16 with surrogate pairs, sometimes he'll want to reject it
>> > (because his program can't handle the situation where one 16 bit value
>> > doesn't represent one character). So the feared combinatorial
>> > explosion is starting.
>> No, that's not a flag, that's another encoding altogether called UCS-16.
>> UTF-16 implies the use of surrogates.

<typo, it's called UCS-2. I was typing too many 16s.>

> The Baby X resource compiler is primarily a utility to help build Baby
> X programs.. Baby X treats all string data as UTF-8, and if a string
> is passed to a non-UTF-8 compatible function then that should be
> considered a bug. So the utf16 tag (input is in any text format,
> output is in UTF-16) doesn't really have a place in Baby X programs.
>
> However I decided to include it, somewhat reluctantly, to support
> non-Baby X users of the resource compiler. But the only real reason
> for using UTF-16, apart from the obvious one, which is to pass to
> third party libaries expecting UTF-16, is to have "wide characters",
> where one "wide character" represents one glyph. If you allow
> surrogate pairs, most of the advantges of UTF-16 over UTF-8 disappear.
>
> So if someone uses the utf16 tag, they probably want to ensure that the data
> contains no surrogate pairs. But not always.

I think you are saying you want to support UTF-16 (as specified --
surrogate pairs and all) but also something you call UTF-16 disallowing
surrogates. Why? The only difference between "UTF-16 disallowing
surrogates" and UCS-2 is the name. The result will most likely just be
confusing to users. It's like offering UTF-8 without multi-byte
characters. That's just called 7-bit ASCII.

--
Ben.

Re: strings or enums?

<3a174fab-6327-48c6-8f05-49b639cc6b8dn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:2b4a:b0:767:f1fc:5297 with SMTP id dp10-20020a05620a2b4a00b00767f1fc5297mr29142qkb.15.1690802632153;
Mon, 31 Jul 2023 04:23:52 -0700 (PDT)
X-Received: by 2002:a67:c31e:0:b0:446:fb4f:c267 with SMTP id
r30-20020a67c31e000000b00446fb4fc267mr70630vsj.4.1690802631872; Mon, 31 Jul
2023 04:23:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.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: Mon, 31 Jul 2023 04:23:51 -0700 (PDT)
In-Reply-To: <87leexw6rg.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:1c70:988a:9a4c:dd97;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:1c70:988a:9a4c:dd97
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<87jzuixxp6.fsf@bsb.me.uk> <416bc8c5-da52-4e46-a536-e678072a5147n@googlegroups.com>
<87r0opwckp.fsf@bsb.me.uk> <5d37902b-3763-4321-9e24-abf8866662a2n@googlegroups.com>
<87leexw6rg.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3a174fab-6327-48c6-8f05-49b639cc6b8dn@googlegroups.com>
Subject: Re: strings or enums?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Mon, 31 Jul 2023 11:23:52 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 6332
 by: Malcolm McLean - Mon, 31 Jul 2023 11:23 UTC

On Sunday, 30 July 2023 at 20:15:31 UTC+1, Ben Bacarisse wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>
> > On Sunday, 30 July 2023 at 18:09:57 UTC+1, Ben Bacarisse wrote:
> >> Malcolm McLean <malcolm.ar...@gmail.com> writes:
> >>
> >> > On Saturday, 29 July 2023 at 21:36:04 UTC+1, Ben Bacarisse wrote:
> >> >> Malcolm McLean <malcolm.ar...@gmail.com> writes:
> >> >>
> >> >> > Do people prefer string or enum arguments to functions taking one of a
> >> >> > restricted list of options? The function I'm writing is
> >> >> >
> >> >> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> >> >> >
> >> >> > If format is an enum, I'd have to create an enum with a list of
> >> >> > formats supported. If it's a string, the caller has to pass one of a
> >> >> > restricted set of formats.
> >> >> I think I'd #define the formats (as you suggest later on).
> >> >> > Advantages to the enum
> >> >> > It's a lot harder to pass a typo or an ill- formed format.
> >> >> > Caller has a list of allowed formats which automatically update.
> >> >> > It's more machine efficent (but won't matter for this function)
> >> >> >
> >> >> > Advantages to the string
> >> >> > Several functions might operate on text file formats. Strings don't
> >> >> > pollute the namespace.
> >> >> > It's easier to print out a human-readable diagnostic at runtime.
> >> >> > It's slightly more natural if the origin of the value is an input string
> >> >> > anyway and not a hard-coded constant.
> >> >> When I first learned Lisp, I could not work out what symbols were
> >> >> supposed to be. They were "things" whose only purposes appeared to be
> >> >> to different from other symbols, but they all sorts of uses, and this is
> >> >> one other them: they are intrinsically human-readable distinct values.
> >> >> > If an exponential combination problem starts, the string can solve it
> >> >> > by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
> >> >> > or "little-endian" . With enums you would have to double the length of the
> >> >> > list.
> >> >> >
> >> >> > The hybrid compromise which we often use at work is to #define
> >> >> > string constants.
> >> >> And you can combine them:
> >> >>
> >> >> decode(filename, ENCODING_UTF_16 | ENCODING_BIG_ENDIAN);
> >> >>
> >> > I've realised there's another flag. Sometimes the user will want to
> >> > accept UTF-16 with surrogate pairs, sometimes he'll want to reject it
> >> > (because his program can't handle the situation where one 16 bit value
> >> > doesn't represent one character). So the feared combinatorial
> >> > explosion is starting.
> >> No, that's not a flag, that's another encoding altogether called UCS-16.
> >> UTF-16 implies the use of surrogates.
> <typo, it's called UCS-2. I was typing too many 16s.>
> > The Baby X resource compiler is primarily a utility to help build Baby
> > X programs.. Baby X treats all string data as UTF-8, and if a string
> > is passed to a non-UTF-8 compatible function then that should be
> > considered a bug. So the utf16 tag (input is in any text format,
> > output is in UTF-16) doesn't really have a place in Baby X programs.
> >
> > However I decided to include it, somewhat reluctantly, to support
> > non-Baby X users of the resource compiler. But the only real reason
> > for using UTF-16, apart from the obvious one, which is to pass to
> > third party libaries expecting UTF-16, is to have "wide characters",
> > where one "wide character" represents one glyph. If you allow
> > surrogate pairs, most of the advantges of UTF-16 over UTF-8 disappear.
> >
> > So if someone uses the utf16 tag, they probably want to ensure that the data
> > contains no surrogate pairs. But not always.
> I think you are saying you want to support UTF-16 (as specified --
> surrogate pairs and all) but also something you call UTF-16 disallowing
> surrogates. Why? The only difference between "UTF-16 disallowing
> surrogates" and UCS-2 is the name. The result will most likely just be
> confusing to users. It's like offering UTF-8 without multi-byte
> characters. That's just called 7-bit ASCII.
>
The <string> tag is designed to export human-readable ASCII (technically
the execution character set of whatever platform the resouce compiler is
running on). the <utf8> tag exports non-human readable UTF-8 as ACSCII-
encoded binary data. If the execution set is EBCDIC, it will still export UTF-8.

The <utf16> tag exports UTF-16 data, encoded as unsigned shorts. But there's
not much point in using this tag if the data contains surrogate pairs (it would
be just as easy to use UTF-8). However yes, you're right. I'm confusing the
import format, which could have surrogate pairs, with the export format, which
should reject them by default. So the <utf8> tag needs a flag to allow surrogate
pairs.

Re: strings or enums?

<uabi6p$3nu9h$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: strings or enums?
Date: Tue, 1 Aug 2023 20:16:56 +0200
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <uabi6p$3nu9h$1@dont-email.me>
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 1 Aug 2023 18:16:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5354df5c48f2ff8ec8d9898b8932e7fa";
logging-data="3930417"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gF9+YzQhQlzx3AOCb4Fh5UmyQQtGq5Hk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:MBD2N9iezgjZEWYpDtn3vgUSlLg=
In-Reply-To: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Tue, 1 Aug 2023 18:16 UTC

On 29/07/2023 12:20, Malcolm McLean wrote:
> Do people prefer string or enum arguments to functions taking one of a restricted list of options?
> The function I'm writing is
>
> char *loadasutf8wthknownformat(const char *filename, format, int *error);
>

If that is a typical example of your function names, then I recommend
you specify the format in Greek but written using the ancient Mongolian
writing system, in order to maintain consistency in the legibility of
the code. Maybe get your cat to type it in.

Alternatively, learn to use capitals or underscore to give the reader a
fighting chance to interpret such names. (The program writer is a lost
cause here.) And /why/, in that 25 character monstrosity, would you
abbreviate "with" to "wth" ?

> If format is an enum, I'd have to create an enum with a list of formats supported. If it's a string, the caller has to pass one of a restricted set of formats.
>

I'd use enums.

> Advantages to the enum
> It's a lot harder to pass a typo or an ill- formed format.
> Caller has a list of allowed formats which automatically update.
> It's more machine efficent (but won't matter for this function)
>
> Advantages to the string
> Several functions might operate on text file formats. Strings don't
> pollute the namespace.

That makes no sense.

> It's easier to print out a human-readable diagnostic at runtime.

That makes no sense. Just have a const array of strings indexed by your
enumeration. (It's a little more complex if you allow combinations of
enum flags.)

> It's slightly more natural if the origin of the value is an input string
> anyway and not a hard-coded constant.

Code has to parse such strings somewhere. Do it earlier, not later.

> If an exponential combination problem starts, the string can solve it
> by parsing. e.g the suffix "le" or "be" could always mean "big-endian"
> or "little-endian" . With enums you would have to double the length of the
> list.
>

Enumeration flags that are all powers of two, combined with |, are a
common and simple solution.

> The hybrid compromise which we often use at work is to #define
> string constants.
>

That combines the worst of all worlds, polluting your namespace (which
you dislike) while allowing typos inside strings.

Re: strings or enums?

<c5da5543-93f5-4afd-bb6b-4b9e18a92218n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:14e6:b0:635:49d7:5445 with SMTP id k6-20020a05621414e600b0063549d75445mr73688qvw.7.1690983023148;
Wed, 02 Aug 2023 06:30:23 -0700 (PDT)
X-Received: by 2002:a05:6808:1909:b0:3a7:4878:233d with SMTP id
bf9-20020a056808190900b003a74878233dmr6829915oib.0.1690983022823; Wed, 02 Aug
2023 06:30:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 2 Aug 2023 06:30:22 -0700 (PDT)
In-Reply-To: <uabi6p$3nu9h$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=92.28.31.24; posting-account=0B-afgoAAABP6274zLUJKa8ZpdIdhsYx
NNTP-Posting-Host: 92.28.31.24
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com> <uabi6p$3nu9h$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c5da5543-93f5-4afd-bb6b-4b9e18a92218n@googlegroups.com>
Subject: Re: strings or enums?
From: gw7...@aol.com (Paul N)
Injection-Date: Wed, 02 Aug 2023 13:30:23 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Paul N - Wed, 2 Aug 2023 13:30 UTC

On Tuesday, August 1, 2023 at 7:17:10 PM UTC+1, David Brown wrote:
> On 29/07/2023 12:20, Malcolm McLean wrote:
> > Do people prefer string or enum arguments to functions taking one of a restricted list of options?

> > It's easier to print out a human-readable diagnostic at runtime.

> That makes no sense. Just have a const array of strings indexed by your
> enumeration. (It's a little more complex if you allow combinations of
> enum flags.)

I beg to differ. Suppose you are accidentally using an older version of the function than you think you are. If you pass in an enum which is out of range, all the function can do is say what the value of the enum is, which the user may not immediately recognise. On the contrary, if you pass in a string saying the option, the function can print the string and say it is not a recognised option. Of course there are pros and cons to both approaches, but Malcolm's point makes sense.

Re: strings or enums?

<30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:181a:b0:40f:e0dd:8050 with SMTP id t26-20020a05622a181a00b0040fe0dd8050mr15452qtc.5.1690990853189;
Wed, 02 Aug 2023 08:40:53 -0700 (PDT)
X-Received: by 2002:a05:6808:1897:b0:3a4:744:e91b with SMTP id
bi23-20020a056808189700b003a40744e91bmr26526471oib.0.1690990852861; Wed, 02
Aug 2023 08:40:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 2 Aug 2023 08:40:52 -0700 (PDT)
In-Reply-To: <uabi6p$3nu9h$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.156; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.156
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com> <uabi6p$3nu9h$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Wed, 02 Aug 2023 15:40:53 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: fir - Wed, 2 Aug 2023 15:40 UTC

wtorek, 1 sierpnia 2023 o 20:17:10 UTC+2 David Brown napisał(a):
> On 29/07/2023 12:20, Malcolm McLean wrote:
> > Do people prefer string or enum arguments to functions taking one of a restricted list of options?
> > The function I'm writing is
> >
> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> >
> If that is a typical example of your function names, then I recommend
> you specify the format in Greek but written using the ancient Mongolian
> writing system, in order to maintain consistency in the legibility of
> the code. Maybe get your cat to type it in.
>
its not so bad its a mattar of style but the abbreviations
are problem - abbreviations simply are nonesense to remember
as you wold need to remember it all and say use one scheme
globally amnog people but its rather nonsense (unless say
special ciricumstances, for exampel you erallny need that)

using strightforward kinda heavy/primitive names as i do
may look heavy and primitive but 'deburdens' you and imo yur
productivity increase..they are also raw good imo..coz they
'infiormational ratio' is simply high

hovever i would not say i have something seriously against
'code stylist' who wrote fancy names.. such names give even
wuite good feeling but the problems are sometimes some other
'gothic' flops, mainly those abbreviations and things resembling macroprocessor

Re: strings or enums?

<da8743da-fca3-4fbd-a491-9e9bd7a3749bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:4a43:b0:63c:fc43:fd51 with SMTP id ph3-20020a0562144a4300b0063cfc43fd51mr75437qvb.11.1690991531675;
Wed, 02 Aug 2023 08:52:11 -0700 (PDT)
X-Received: by 2002:a05:6870:1a81:b0:1bb:6ec5:1009 with SMTP id
ef1-20020a0568701a8100b001bb6ec51009mr17604034oab.11.1690991531345; Wed, 02
Aug 2023 08:52:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 2 Aug 2023 08:52:10 -0700 (PDT)
In-Reply-To: <uabi6p$3nu9h$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:744e:7d28:9b48:49e0;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:744e:7d28:9b48:49e0
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com> <uabi6p$3nu9h$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <da8743da-fca3-4fbd-a491-9e9bd7a3749bn@googlegroups.com>
Subject: Re: strings or enums?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Wed, 02 Aug 2023 15:52:11 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Malcolm McLean - Wed, 2 Aug 2023 15:52 UTC

On Tuesday, 1 August 2023 at 19:17:10 UTC+1, David Brown wrote:
> On 29/07/2023 12:20, Malcolm McLean wrote:
> > Do people prefer string or enum arguments to functions taking one of a restricted list of options?
> > The function I'm writing is
> >
> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> >
> If that is a typical example of your function names, then I recommend
> you specify the format in Greek but written using the ancient Mongolian
> writing system, in order to maintain consistency in the legibility of
> the code. Maybe get your cat to type it in.
>
There's a case for folding it into loadasutf8() and passing in a null or "automatic"
format parameter to indicate that the function should resort to automatic
detection. However once we have the "load with known format" function,
we can write loadasutf8(), unknown format, on top of it, which might be more
logical.

Re: strings or enums?

<762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:7d96:0:b0:40e:b4f2:b38e with SMTP id c22-20020ac87d96000000b0040eb4f2b38emr60188qtd.2.1690991652801;
Wed, 02 Aug 2023 08:54:12 -0700 (PDT)
X-Received: by 2002:a05:6808:1790:b0:3a7:6251:985d with SMTP id
bg16-20020a056808179000b003a76251985dmr454233oib.4.1690991652644; Wed, 02 Aug
2023 08:54:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.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: Wed, 2 Aug 2023 08:54:12 -0700 (PDT)
In-Reply-To: <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.156; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.156
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me> <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Wed, 02 Aug 2023 15:54:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3787
 by: fir - Wed, 2 Aug 2023 15:54 UTC

środa, 2 sierpnia 2023 o 17:41:00 UTC+2 fir napisał(a):
> wtorek, 1 sierpnia 2023 o 20:17:10 UTC+2 David Brown napisał(a):
> > On 29/07/2023 12:20, Malcolm McLean wrote:
> > > Do people prefer string or enum arguments to functions taking one of a restricted list of options?
> > > The function I'm writing is
> > >
> > > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> > >
> > If that is a typical example of your function names, then I recommend
> > you specify the format in Greek but written using the ancient Mongolian
> > writing system, in order to maintain consistency in the legibility of
> > the code. Maybe get your cat to type it in.
> >
> its not so bad its a mattar of style but the abbreviations
> are problem - abbreviations simply are nonesense to remember
> as you wold need to remember it all and say use one scheme
> globally amnog people but its rather nonsense (unless say
> special ciricumstances, for exampel you erallny need that)
>
> using strightforward kinda heavy/primitive names as i do
> may look heavy and primitive but 'deburdens' you and imo yur
> productivity increase..they are also raw good imo..coz they
> 'infiormational ratio' is simply high
>
> hovever i would not say i have something seriously against
> 'code stylist' who wrote fancy names.. such names give even
> wuite good feeling but the problems are sometimes some other
> 'gothic' flops, mainly those abbreviations and things resembling macroprocessor

some could say that my 'mixed' approach (as i use pascal for functions and c shorts (no 'skipspaces' though) and lowcase_underscores for locals and variables its not stylistically to much good as its mixed and sometimes looks liek a salad with a lot of green peas - but it work well, so maybe i chosen it more by experimentation how it work than how it look

c overally has two styles of code itself imo, one is humanistical creative (and here you got a lot of pascal function names) and the second is more optimistation and ram related - on variables with underscores) and it is also seen here as lots of my code are lot of pascal and few optimisation routines are lot of underscores.. you maty say its uncoherent but those two types of codes are uncoherent with each other..writing humnistic code with underscores im not sure as to this, writing opt-code with camels more ok but underscores fit

Re: strings or enums?

<d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ae9:df01:0:b0:763:a36e:19bc with SMTP id t1-20020ae9df01000000b00763a36e19bcmr69086qkf.5.1690992011752;
Wed, 02 Aug 2023 09:00:11 -0700 (PDT)
X-Received: by 2002:a05:6830:1e01:b0:6bc:9370:efb4 with SMTP id
s1-20020a0568301e0100b006bc9370efb4mr12835856otr.0.1690992011454; Wed, 02 Aug
2023 09:00:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 2 Aug 2023 09:00:11 -0700 (PDT)
In-Reply-To: <762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:744e:7d28:9b48:49e0;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:744e:7d28:9b48:49e0
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me> <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
<762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>
Subject: Re: strings or enums?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Wed, 02 Aug 2023 16:00:11 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Malcolm McLean - Wed, 2 Aug 2023 16:00 UTC

On Wednesday, 2 August 2023 at 16:54:21 UTC+1, fir wrote:
> środa, 2 sierpnia 2023 o 17:41:00 UTC+2 fir napisał(a):
> > wtorek, 1 sierpnia 2023 o 20:17:10 UTC+2 David Brown napisał(a):
> > > On 29/07/2023 12:20, Malcolm McLean wrote:
> > > > Do people prefer string or enum arguments to functions taking one of a restricted list of options?
> > > > The function I'm writing is
> > > >
> > > > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> > > >
> > > If that is a typical example of your function names, then I recommend
> > > you specify the format in Greek but written using the ancient Mongolian
> > > writing system, in order to maintain consistency in the legibility of
> > > the code. Maybe get your cat to type it in.
> > >
> > its not so bad its a mattar of style but the abbreviations
> > are problem - abbreviations simply are nonesense to remember
> > as you wold need to remember it all and say use one scheme
> > globally amnog people but its rather nonsense (unless say
> > special ciricumstances, for exampel you erallny need that)
> >
> > using strightforward kinda heavy/primitive names as i do
> > may look heavy and primitive but 'deburdens' you and imo yur
> > productivity increase..they are also raw good imo..coz they
> > 'infiormational ratio' is simply high
> >
> > hovever i would not say i have something seriously against
> > 'code stylist' who wrote fancy names.. such names give even
> > wuite good feeling but the problems are sometimes some other
> > 'gothic' flops, mainly those abbreviations and things resembling macroprocessor
> some could say that my 'mixed' approach (as i use pascal for functions and c shorts (no 'skipspaces' though) and lowcase_underscores for locals and variables its not stylistically to much good as its mixed and sometimes looks liek a salad with a lot of green peas - but it work well, so maybe i chosen it more by experimentation how it work than how it look
>
> c overally has two styles of code itself imo, one is humanistical creative (and here you got a lot of pascal function names) and the second is more optimistation and ram related - on variables with underscores) and it is also seen here as lots of my code are lot of pascal and few optimisation routines are lot of underscores.. you maty say its uncoherent but those two types of codes are uncoherent with each other..writing humnistic code with underscores im not sure as to this, writing opt-code with camels more ok but underscores fit
>
If whitespace is disallowed, humans prefer names which are simply concatenated. Computers find
it easier to deal with underscores.

Re: strings or enums?

<088f897f-5085-4cb6-9d94-54e08cf2091fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:58f1:0:b0:63c:fcbe:b114 with SMTP id di17-20020ad458f1000000b0063cfcbeb114mr76459qvb.0.1690992853325;
Wed, 02 Aug 2023 09:14:13 -0700 (PDT)
X-Received: by 2002:a05:6870:3a04:b0:1bb:ad9e:2978 with SMTP id
du4-20020a0568703a0400b001bbad9e2978mr17592398oab.10.1690992853040; Wed, 02
Aug 2023 09:14:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.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: Wed, 2 Aug 2023 09:14:12 -0700 (PDT)
In-Reply-To: <d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.156; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.156
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me> <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
<762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com> <d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <088f897f-5085-4cb6-9d94-54e08cf2091fn@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Wed, 02 Aug 2023 16:14:13 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5728
 by: fir - Wed, 2 Aug 2023 16:14 UTC

środa, 2 sierpnia 2023 o 18:00:20 UTC+2 Malcolm McLean napisał(a):
> On Wednesday, 2 August 2023 at 16:54:21 UTC+1, fir wrote:
> > środa, 2 sierpnia 2023 o 17:41:00 UTC+2 fir napisał(a):
> > > wtorek, 1 sierpnia 2023 o 20:17:10 UTC+2 David Brown napisał(a):
> > > > On 29/07/2023 12:20, Malcolm McLean wrote:
> > > > > Do people prefer string or enum arguments to functions taking one of a restricted list of options?
> > > > > The function I'm writing is
> > > > >
> > > > > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> > > > >
> > > > If that is a typical example of your function names, then I recommend
> > > > you specify the format in Greek but written using the ancient Mongolian
> > > > writing system, in order to maintain consistency in the legibility of
> > > > the code. Maybe get your cat to type it in.
> > > >
> > > its not so bad its a mattar of style but the abbreviations
> > > are problem - abbreviations simply are nonesense to remember
> > > as you wold need to remember it all and say use one scheme
> > > globally amnog people but its rather nonsense (unless say
> > > special ciricumstances, for exampel you erallny need that)
> > >
> > > using strightforward kinda heavy/primitive names as i do
> > > may look heavy and primitive but 'deburdens' you and imo yur
> > > productivity increase..they are also raw good imo..coz they
> > > 'infiormational ratio' is simply high
> > >
> > > hovever i would not say i have something seriously against
> > > 'code stylist' who wrote fancy names.. such names give even
> > > wuite good feeling but the problems are sometimes some other
> > > 'gothic' flops, mainly those abbreviations and things resembling macroprocessor
> > some could say that my 'mixed' approach (as i use pascal for functions and c shorts (no 'skipspaces' though) and lowcase_underscores for locals and variables its not stylistically to much good as its mixed and sometimes looks liek a salad with a lot of green peas - but it work well, so maybe i chosen it more by experimentation how it work than how it look
> >
> > c overally has two styles of code itself imo, one is humanistical creative (and here you got a lot of pascal function names) and the second is more optimistation and ram related - on variables with underscores) and it is also seen here as lots of my code are lot of pascal and few optimisation routines are lot of underscores.. you maty say its uncoherent but those two types of codes are uncoherent with each other..writing humnistic code with underscores im not sure as to this, writing opt-code with camels more ok but underscores fit
> >
> If whitespace is disallowed, humans prefer names which are simply concatenated. Computers find
> it easier to deal with underscores.

you mean humens prefer
char *loadasutf8wthknownformat(const char *filename, format, int *error);

? i dont think so.. (i name it 'skipspaces' style and never use it)

char *load_as_utf8_with_known_format(const char *filename, format, int *error);

lowcase underscore - betetr but imo nut much suitable for function names (unles maybe those who are terrubly optimisation related)
(skiping the sentence itself is maybe not much best, as those names with with are wierd imo.. it rather should have noun to make proper sentence non load but not specified what which is 'form' sentence not a sentence )
char *LoadAsUtf8WithKnownFormat(const char *filename, format, int *error);

char *LoadFileAsUtf8WithKnownFormat(const char *filename, format, int *error);
//better...thsi "WithKnown" could be rewritten for something more informative but i dont know what it exactly means in context of the code (and names shoudl say on the context not just as separate function) (hovever this "with known" in fact says something on context but it could bereohrased better i guess - and it is really important to sometimes think 10 seconds on exact name

i somethimes think...(in fact i always think - but sometimes if i cant find the godo name fast i write worse intentionally not to stop productivity.. but i think each time)

Re: strings or enums?

<7ovyM.258065$qnnb.55117@fx11.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.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: strings or enums?
Newsgroups: comp.lang.c
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com> <uabi6p$3nu9h$1@dont-email.me> <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com> <762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com> <d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com> <088f897f-5085-4cb6-9d94-54e08cf2091fn@googlegroups.com>
Lines: 73
Message-ID: <7ovyM.258065$qnnb.55117@fx11.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 02 Aug 2023 16:21:23 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 02 Aug 2023 16:21:23 GMT
X-Received-Bytes: 4414
 by: Scott Lurndal - Wed, 2 Aug 2023 16:21 UTC

fir <profesor.fir@gmail.com> writes:
>=C5=9Broda, 2 sierpnia 2023 o=C2=A018:00:20 UTC+2 Malcolm McLean napisa=C5=
>=82(a):
>> On Wednesday, 2 August 2023 at 16:54:21 UTC+1, fir wrote:=20
>> > =C5=9Broda, 2 sierpnia 2023 o 17:41:00 UTC+2 fir napisa=C5=82(a):=20
>> > > wtorek, 1 sierpnia 2023 o 20:17:10 UTC+2 David Brown napisa=C5=82(a):=
>=20
>> > > > On 29/07/2023 12:20, Malcolm McLean wrote:=20
>> > > > > Do people prefer string or enum arguments to functions taking one=
> of a restricted list of options?=20
>> > > > > The function I'm writing is=20
>> > > > >=20
>> > > > > char *loadasutf8wthknownformat(const char *filename, format, int =
>*error);=20
>> > > > >=20
>> > > > If that is a typical example of your function names, then I recomme=
>nd=20
>> > > > you specify the format in Greek but written using the ancient Mongo=
>lian=20
>> > > > writing system, in order to maintain consistency in the legibility =
>of=20
>> > > > the code. Maybe get your cat to type it in.=20
>> > > >=20
>> > > its not so bad its a mattar of style but the abbreviations=20
>> > > are problem - abbreviations simply are nonesense to remember=20
>> > > as you wold need to remember it all and say use one scheme=20
>> > > globally amnog people but its rather nonsense (unless say=20
>> > > special ciricumstances, for exampel you erallny need that)=20
>> > >=20
>> > > using strightforward kinda heavy/primitive names as i do=20
>> > > may look heavy and primitive but 'deburdens' you and imo yur=20
>> > > productivity increase..they are also raw good imo..coz they=20
>> > > 'infiormational ratio' is simply high=20
>> > >=20
>> > > hovever i would not say i have something seriously against=20
>> > > 'code stylist' who wrote fancy names.. such names give even=20
>> > > wuite good feeling but the problems are sometimes some other=20
>> > > 'gothic' flops, mainly those abbreviations and things resembling macr=
>oprocessor=20
>> > some could say that my 'mixed' approach (as i use pascal for functions =
>and c shorts (no 'skipspaces' though) and lowcase_underscores for locals an=
>d variables its not stylistically to much good as its mixed and sometimes l=
>ooks liek a salad with a lot of green peas - but it work well, so maybe i c=
>hosen it more by experimentation how it work than how it look=20
>> >=20
>> > c overally has two styles of code itself imo, one is humanistical creat=
>ive (and here you got a lot of pascal function names) and the second is mor=
>e optimistation and ram related - on variables with underscores) and it is =
>also seen here as lots of my code are lot of pascal and few optimisation ro=
>utines are lot of underscores.. you maty say its uncoherent but those two t=
>ypes of codes are uncoherent with each other..writing humnistic code with u=
>nderscores im not sure as to this, writing opt-code with camels more ok but=
> underscores fit=20
>> >
>> If whitespace is disallowed, humans prefer names which are simply concate=
>nated. Computers find=20
>> it easier to deal with underscores.
>
>you mean humens prefer
> char *loadasutf8wthknownformat(const char *filename, format, int *error);

I prefer

char *load(const char *filename, format_t input format, error_t *error);

char *result = load(argv[1], F_UTF8, &error);
if (error != SUCCESS) {
fprintf(stderr, "Unable to load '%s' when interpreting as UTF-8", argv[1]);
return LOAD_FORMAT_FAILURE;
}

Re: strings or enums?

<f9f3b67a-3200-4e95-97a9-e0c3e42d34fan@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:1725:b0:76a:d9a6:a8d0 with SMTP id az37-20020a05620a172500b0076ad9a6a8d0mr128745qkb.1.1690993328289;
Wed, 02 Aug 2023 09:22:08 -0700 (PDT)
X-Received: by 2002:a05:6808:189e:b0:3a7:2434:615a with SMTP id
bi30-20020a056808189e00b003a72434615amr16624783oib.4.1690993327997; Wed, 02
Aug 2023 09:22:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.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: Wed, 2 Aug 2023 09:22:07 -0700 (PDT)
In-Reply-To: <088f897f-5085-4cb6-9d94-54e08cf2091fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.156; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.156
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me> <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
<762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com> <d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>
<088f897f-5085-4cb6-9d94-54e08cf2091fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f9f3b67a-3200-4e95-97a9-e0c3e42d34fan@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Wed, 02 Aug 2023 16:22:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 6292
 by: fir - Wed, 2 Aug 2023 16:22 UTC

środa, 2 sierpnia 2023 o 18:14:22 UTC+2 fir napisał(a):
> środa, 2 sierpnia 2023 o 18:00:20 UTC+2 Malcolm McLean napisał(a):
> > On Wednesday, 2 August 2023 at 16:54:21 UTC+1, fir wrote:
> > > środa, 2 sierpnia 2023 o 17:41:00 UTC+2 fir napisał(a):
> > > > wtorek, 1 sierpnia 2023 o 20:17:10 UTC+2 David Brown napisał(a):
> > > > > On 29/07/2023 12:20, Malcolm McLean wrote:
> > > > > > Do people prefer string or enum arguments to functions taking one of a restricted list of options?
> > > > > > The function I'm writing is
> > > > > >
> > > > > > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> > > > > >
> > > > > If that is a typical example of your function names, then I recommend
> > > > > you specify the format in Greek but written using the ancient Mongolian
> > > > > writing system, in order to maintain consistency in the legibility of
> > > > > the code. Maybe get your cat to type it in.
> > > > >
> > > > its not so bad its a mattar of style but the abbreviations
> > > > are problem - abbreviations simply are nonesense to remember
> > > > as you wold need to remember it all and say use one scheme
> > > > globally amnog people but its rather nonsense (unless say
> > > > special ciricumstances, for exampel you erallny need that)
> > > >
> > > > using strightforward kinda heavy/primitive names as i do
> > > > may look heavy and primitive but 'deburdens' you and imo yur
> > > > productivity increase..they are also raw good imo..coz they
> > > > 'infiormational ratio' is simply high
> > > >
> > > > hovever i would not say i have something seriously against
> > > > 'code stylist' who wrote fancy names.. such names give even
> > > > wuite good feeling but the problems are sometimes some other
> > > > 'gothic' flops, mainly those abbreviations and things resembling macroprocessor
> > > some could say that my 'mixed' approach (as i use pascal for functions and c shorts (no 'skipspaces' though) and lowcase_underscores for locals and variables its not stylistically to much good as its mixed and sometimes looks liek a salad with a lot of green peas - but it work well, so maybe i chosen it more by experimentation how it work than how it look
> > >
> > > c overally has two styles of code itself imo, one is humanistical creative (and here you got a lot of pascal function names) and the second is more optimistation and ram related - on variables with underscores) and it is also seen here as lots of my code are lot of pascal and few optimisation routines are lot of underscores.. you maty say its uncoherent but those two types of codes are uncoherent with each other..writing humnistic code with underscores im not sure as to this, writing opt-code with camels more ok but underscores fit
> > >
> > If whitespace is disallowed, humans prefer names which are simply concatenated. Computers find
> > it easier to deal with underscores.
> you mean humens prefer
> char *loadasutf8wthknownformat(const char *filename, format, int *error);
> ? i dont think so.. (i name it 'skipspaces' style and never use it)
>
> char *load_as_utf8_with_known_format(const char *filename, format, int *error);
>
> lowcase underscore - betetr but imo nut much suitable for function names (unles maybe those who are terrubly optimisation related)
> (skiping the sentence itself is maybe not much best, as those names with with are wierd imo.. it rather should have noun to make proper sentence non load but not specified what which is 'form' sentence not a sentence )
> char *LoadAsUtf8WithKnownFormat(const char *filename, format, int *error);
>
> char *LoadFileAsUtf8WithKnownFormat(const char *filename, format, int *error);
> //better...thsi "WithKnown" could be rewritten for something more informative but i dont know what it exactly means in context of the code (and names shoudl say on the context not just as separate function) (hovever this "with known" in fact says something on context but it could bereohrased better i guess - and it is really important to sometimes think 10 seconds on exact name
>
> i somethimes think...(in fact i always think - but sometimes if i cant find the godo name fast i write worse intentionally not to stop productivity... but i think each time)

eventually i would turn thiw WithKnown into Knowing
(asumming you rad file into ram file in Utf8 knowing input format which you detected by separate function just before

- i dont write comments (unles rare things i just need to note something special, like wikipedia-like fact) so the proper names takes work

Re: strings or enums?

<89e0c7c4-cbaf-4ac0-8f9c-e6c081ccdb56n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:19aa:b0:403:edaf:5b78 with SMTP id u42-20020a05622a19aa00b00403edaf5b78mr74830qtc.6.1690993410926;
Wed, 02 Aug 2023 09:23:30 -0700 (PDT)
X-Received: by 2002:a05:6830:33dc:b0:6b9:97f6:655 with SMTP id
q28-20020a05683033dc00b006b997f60655mr16239143ott.2.1690993410605; Wed, 02
Aug 2023 09:23:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 2 Aug 2023 09:23:30 -0700 (PDT)
In-Reply-To: <7ovyM.258065$qnnb.55117@fx11.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.156; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.156
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me> <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
<762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com> <d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>
<088f897f-5085-4cb6-9d94-54e08cf2091fn@googlegroups.com> <7ovyM.258065$qnnb.55117@fx11.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <89e0c7c4-cbaf-4ac0-8f9c-e6c081ccdb56n@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Wed, 02 Aug 2023 16:23:30 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: fir - Wed, 2 Aug 2023 16:23 UTC

środa, 2 sierpnia 2023 o 18:21:37 UTC+2 Scott Lurndal napisał(a):
> fir <profes...@gmail.com> writes:
> >=C5=9Broda, 2 sierpnia 2023 o=C2=A018:00:20 UTC+2 Malcolm McLean napisa=C5=
> >=82(a):
> >> On Wednesday, 2 August 2023 at 16:54:21 UTC+1, fir wrote:=20
> >> > =C5=9Broda, 2 sierpnia 2023 o 17:41:00 UTC+2 fir napisa=C5=82(a):=20
> >> > > wtorek, 1 sierpnia 2023 o 20:17:10 UTC+2 David Brown napisa=C5=82(a):=
> >=20
> >> > > > On 29/07/2023 12:20, Malcolm McLean wrote:=20
> >> > > > > Do people prefer string or enum arguments to functions taking one=
> > of a restricted list of options?=20
> >> > > > > The function I'm writing is=20
> >> > > > >=20
> >> > > > > char *loadasutf8wthknownformat(const char *filename, format, int =
> >*error);=20
> >> > > > >=20
> >> > > > If that is a typical example of your function names, then I recomme=
> >nd=20
> >> > > > you specify the format in Greek but written using the ancient Mongo=
> >lian=20
> >> > > > writing system, in order to maintain consistency in the legibility =
> >of=20
> >> > > > the code. Maybe get your cat to type it in.=20
> >> > > >=20
> >> > > its not so bad its a mattar of style but the abbreviations=20
> >> > > are problem - abbreviations simply are nonesense to remember=20
> >> > > as you wold need to remember it all and say use one scheme=20
> >> > > globally amnog people but its rather nonsense (unless say=20
> >> > > special ciricumstances, for exampel you erallny need that)=20
> >> > >=20
> >> > > using strightforward kinda heavy/primitive names as i do=20
> >> > > may look heavy and primitive but 'deburdens' you and imo yur=20
> >> > > productivity increase..they are also raw good imo..coz they=20
> >> > > 'infiormational ratio' is simply high=20
> >> > >=20
> >> > > hovever i would not say i have something seriously against=20
> >> > > 'code stylist' who wrote fancy names.. such names give even=20
> >> > > wuite good feeling but the problems are sometimes some other=20
> >> > > 'gothic' flops, mainly those abbreviations and things resembling macr=
> >oprocessor=20
> >> > some could say that my 'mixed' approach (as i use pascal for functions =
> >and c shorts (no 'skipspaces' though) and lowcase_underscores for locals an=
> >d variables its not stylistically to much good as its mixed and sometimes l=
> >ooks liek a salad with a lot of green peas - but it work well, so maybe i c=
> >hosen it more by experimentation how it work than how it look=20
> >> >=20
> >> > c overally has two styles of code itself imo, one is humanistical creat=
> >ive (and here you got a lot of pascal function names) and the second is mor=
> >e optimistation and ram related - on variables with underscores) and it is =
> >also seen here as lots of my code are lot of pascal and few optimisation ro=
> >utines are lot of underscores.. you maty say its uncoherent but those two t=
> >ypes of codes are uncoherent with each other..writing humnistic code with u=
> >nderscores im not sure as to this, writing opt-code with camels more ok but=
> > underscores fit=20
> >> >
> >> If whitespace is disallowed, humans prefer names which are simply concate=
> >nated. Computers find=20
> >> it easier to deal with underscores.
> >
> >you mean humens prefer
> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> I prefer
>
> char *load(const char *filename, format_t input format, error_t *error);
>
>
> char *result = load(argv[1], F_UTF8, &error);
> if (error != SUCCESS) {
> fprintf(stderr, "Unable to load '%s' when interpreting as UTF-8", argv[1]);
> return LOAD_FORMAT_FAILURE;
> }

bad (..what is wrote is imo the best of what was mentioned )

Re: strings or enums?

<uae04h$5hi1$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: strings or enums?
Date: Wed, 2 Aug 2023 18:26:57 +0200
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <uae04h$5hi1$2@dont-email.me>
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me>
<c5da5543-93f5-4afd-bb6b-4b9e18a92218n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Aug 2023 16:26:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="46e2fd4c97e01cfd809944807e1c85c2";
logging-data="181825"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vut1UoLJbWhDWbUlFWgzenjSGRQTrpj0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:gOt9OLaAYMGqIQoIlQEY5lOMdTw=
In-Reply-To: <c5da5543-93f5-4afd-bb6b-4b9e18a92218n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Wed, 2 Aug 2023 16:26 UTC

On 02/08/2023 15:30, Paul N wrote:
> On Tuesday, August 1, 2023 at 7:17:10 PM UTC+1, David Brown wrote:
>> On 29/07/2023 12:20, Malcolm McLean wrote:
>>> Do people prefer string or enum arguments to functions taking one of a restricted list of options?
>
>>> It's easier to print out a human-readable diagnostic at runtime.
>
>> That makes no sense. Just have a const array of strings indexed by your
>> enumeration. (It's a little more complex if you allow combinations of
>> enum flags.)
>
> I beg to differ. Suppose you are accidentally using an older version of the function than you think you are. If you pass in an enum which is out of range, all the function can do is say what the value of the enum is, which the user may not immediately recognise. On the contrary, if you pass in a string saying the option, the function can print the string and say it is not a recognised option. Of course there are pros and cons to both approaches, but Malcolm's point makes sense.
>

If only there were a way to avoid that kind of problem. What we really
need is a way to have a common piece of code - a "header" file, if you
will - where you could put function declarations and enum declarations
all in one place. Then you could "include" that file in C files that
define your functions, and in C files that use the functions, and have
everything automatically consistent!

Maybe we could go even further, and /document/ the functions and types?

Re: strings or enums?

<uae079$5hi1$3@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: strings or enums?
Date: Wed, 2 Aug 2023 18:28:24 +0200
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <uae079$5hi1$3@dont-email.me>
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me>
<30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
<762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com>
<d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Aug 2023 16:28:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="46e2fd4c97e01cfd809944807e1c85c2";
logging-data="181825"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UlUhrvwYel3/nrpU4AiYWPBUP7oC0IF0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:86YGIJmPflvhYBqJzyU6cOyGoMQ=
Content-Language: en-GB
In-Reply-To: <d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>
 by: David Brown - Wed, 2 Aug 2023 16:28 UTC

On 02/08/2023 18:00, Malcolm McLean wrote:

> If whitespace is disallowed, humans prefer names which are simply concatenated.

You do not speak for humanity.

Re: strings or enums?

<659a1e40-8025-4c94-a013-00d261224b2en@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:4e47:0:b0:635:dd39:e32 with SMTP id eb7-20020ad44e47000000b00635dd390e32mr80455qvb.5.1690993733477;
Wed, 02 Aug 2023 09:28:53 -0700 (PDT)
X-Received: by 2002:a05:6870:c7a9:b0:1bb:715a:4b1f with SMTP id
dy41-20020a056870c7a900b001bb715a4b1fmr16945877oab.0.1690993733173; Wed, 02
Aug 2023 09:28:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.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: Wed, 2 Aug 2023 09:28:52 -0700 (PDT)
In-Reply-To: <7ovyM.258065$qnnb.55117@fx11.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=81.143.231.9; posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 81.143.231.9
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me> <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
<762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com> <d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>
<088f897f-5085-4cb6-9d94-54e08cf2091fn@googlegroups.com> <7ovyM.258065$qnnb.55117@fx11.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <659a1e40-8025-4c94-a013-00d261224b2en@googlegroups.com>
Subject: Re: strings or enums?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Wed, 02 Aug 2023 16:28:53 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 5438
 by: Malcolm McLean - Wed, 2 Aug 2023 16:28 UTC

On Wednesday, 2 August 2023 at 17:21:37 UTC+1, Scott Lurndal wrote:
> fir <profes...@gmail.com> writes:
> >=C5=9Broda, 2 sierpnia 2023 o=C2=A018:00:20 UTC+2 Malcolm McLean napisa=C5=
> >=82(a):
> >> On Wednesday, 2 August 2023 at 16:54:21 UTC+1, fir wrote:=20
> >> > =C5=9Broda, 2 sierpnia 2023 o 17:41:00 UTC+2 fir napisa=C5=82(a):=20
> >> > > wtorek, 1 sierpnia 2023 o 20:17:10 UTC+2 David Brown napisa=C5=82(a):=
> >=20
> >> > > > On 29/07/2023 12:20, Malcolm McLean wrote:=20
> >> > > > > Do people prefer string or enum arguments to functions taking one=
> > of a restricted list of options?=20
> >> > > > > The function I'm writing is=20
> >> > > > >=20
> >> > > > > char *loadasutf8wthknownformat(const char *filename, format, int =
> >*error);=20
> >> > > > >=20
> >> > > > If that is a typical example of your function names, then I recomme=
> >nd=20
> >> > > > you specify the format in Greek but written using the ancient Mongo=
> >lian=20
> >> > > > writing system, in order to maintain consistency in the legibility =
> >of=20
> >> > > > the code. Maybe get your cat to type it in.=20
> >> > > >=20
> >> > > its not so bad its a mattar of style but the abbreviations=20
> >> > > are problem - abbreviations simply are nonesense to remember=20
> >> > > as you wold need to remember it all and say use one scheme=20
> >> > > globally amnog people but its rather nonsense (unless say=20
> >> > > special ciricumstances, for exampel you erallny need that)=20
> >> > >=20
> >> > > using strightforward kinda heavy/primitive names as i do=20
> >> > > may look heavy and primitive but 'deburdens' you and imo yur=20
> >> > > productivity increase..they are also raw good imo..coz they=20
> >> > > 'infiormational ratio' is simply high=20
> >> > >=20
> >> > > hovever i would not say i have something seriously against=20
> >> > > 'code stylist' who wrote fancy names.. such names give even=20
> >> > > wuite good feeling but the problems are sometimes some other=20
> >> > > 'gothic' flops, mainly those abbreviations and things resembling macr=
> >oprocessor=20
> >> > some could say that my 'mixed' approach (as i use pascal for functions =
> >and c shorts (no 'skipspaces' though) and lowcase_underscores for locals an=
> >d variables its not stylistically to much good as its mixed and sometimes l=
> >ooks liek a salad with a lot of green peas - but it work well, so maybe i c=
> >hosen it more by experimentation how it work than how it look=20
> >> >=20
> >> > c overally has two styles of code itself imo, one is humanistical creat=
> >ive (and here you got a lot of pascal function names) and the second is mor=
> >e optimistation and ram related - on variables with underscores) and it is =
> >also seen here as lots of my code are lot of pascal and few optimisation ro=
> >utines are lot of underscores.. you maty say its uncoherent but those two t=
> >ypes of codes are uncoherent with each other..writing humnistic code with u=
> >nderscores im not sure as to this, writing opt-code with camels more ok but=
> > underscores fit=20
> >> >
> >> If whitespace is disallowed, humans prefer names which are simply concate=
> >nated. Computers find=20
> >> it easier to deal with underscores.
> >
> >you mean humens prefer
> > char *loadasutf8wthknownformat(const char *filename, format, int *error);
> I prefer
>
> char *load(const char *filename, format_t input format, error_t *error);
>
>
> char *result = load(argv[1], F_UTF8, &error);
> if (error != SUCCESS) {
> fprintf(stderr, "Unable to load '%s' when interpreting as UTF-8", argv[1]);
> return LOAD_FORMAT_FAILURE;
> }
>
The three errors that are likely are out of memory, IO (usually can't open the file
because it is locked or doesn't exist, but can be a problem with the backing store
device), and parse error. Which is why you need an error parameter. Often just
:failed to load file" isn't informaitve enough for the user.

Re: strings or enums?

<uae09m$5hi1$4@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: strings or enums?
Date: Wed, 2 Aug 2023 18:29:42 +0200
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <uae09m$5hi1$4@dont-email.me>
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me>
<da8743da-fca3-4fbd-a491-9e9bd7a3749bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Aug 2023 16:29:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="46e2fd4c97e01cfd809944807e1c85c2";
logging-data="181825"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182BkPDZdvOMR+hehk+cUYOrwBgZktTkQc="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:lXhjxxDcfIXzkiBA+sMEIl+zui4=
Content-Language: en-GB
In-Reply-To: <da8743da-fca3-4fbd-a491-9e9bd7a3749bn@googlegroups.com>
 by: David Brown - Wed, 2 Aug 2023 16:29 UTC

On 02/08/2023 17:52, Malcolm McLean wrote:
> On Tuesday, 1 August 2023 at 19:17:10 UTC+1, David Brown wrote:
>> On 29/07/2023 12:20, Malcolm McLean wrote:
>>> Do people prefer string or enum arguments to functions taking one of a restricted list of options?
>>> The function I'm writing is
>>>
>>> char *loadasutf8wthknownformat(const char *filename, format, int *error);
>>>
>> If that is a typical example of your function names, then I recommend
>> you specify the format in Greek but written using the ancient Mongolian
>> writing system, in order to maintain consistency in the legibility of
>> the code. Maybe get your cat to type it in.
>>
> There's a case for folding it into loadasutf8() and passing in a null or "automatic"
> format parameter to indicate that the function should resort to automatic
> detection. However once we have the "load with known format" function,
> we can write loadasutf8(), unknown format, on top of it, which might be more
> logical.
>

There are a dozen ways to do better than the monstrosity you have above.
Pick whatever suits you.

Re: strings or enums?

<d1cc0127-2461-4d44-8337-e11708a00633n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:946:b0:63d:3755:3860 with SMTP id dn6-20020a056214094600b0063d37553860mr74996qvb.9.1690993839217;
Wed, 02 Aug 2023 09:30:39 -0700 (PDT)
X-Received: by 2002:a05:622a:8b:b0:40d:4c6:bcf4 with SMTP id
o11-20020a05622a008b00b0040d04c6bcf4mr63796qtw.9.1690993839054; Wed, 02 Aug
2023 09:30:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.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: Wed, 2 Aug 2023 09:30:38 -0700 (PDT)
In-Reply-To: <uae079$5hi1$3@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=81.143.231.9; posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 81.143.231.9
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me> <30ab3a27-dbe4-40ad-ad18-23f4123a56c9n@googlegroups.com>
<762748f4-bfc8-4927-845d-940ee59ed838n@googlegroups.com> <d6c26268-3b2a-4b84-85ce-f372030f7071n@googlegroups.com>
<uae079$5hi1$3@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d1cc0127-2461-4d44-8337-e11708a00633n@googlegroups.com>
Subject: Re: strings or enums?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Wed, 02 Aug 2023 16:30:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1647
 by: Malcolm McLean - Wed, 2 Aug 2023 16:30 UTC

On Wednesday, 2 August 2023 at 17:28:39 UTC+1, David Brown wrote:
> On 02/08/2023 18:00, Malcolm McLean wrote:
>
> > If whitespace is disallowed, humans prefer names which are simply concatenated.
> You do not speak for humanity.
Experiments have been done. I can't remember the references off the top of
my head.

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor