Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

It seems intuitively obvious to me, which means that it might be wrong. -- Chris Torek


devel / comp.lang.c / Re: 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
Re: strings or enums?

<81886bb6-1839-4ee3-a134-9fa0bc84c87fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ae9:de03:0:b0:76c:9ec6:48e1 with SMTP id s3-20020ae9de03000000b0076c9ec648e1mr61151qkf.3.1690995652379;
Wed, 02 Aug 2023 10:00:52 -0700 (PDT)
X-Received: by 2002:a4a:374a:0:b0:56c:58a0:302f with SMTP id
r71-20020a4a374a000000b0056c58a0302fmr13259495oor.0.1690995652053; Wed, 02
Aug 2023 10:00: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 10:00:51 -0700 (PDT)
In-Reply-To: <89e0c7c4-cbaf-4ac0-8f9c-e6c081ccdb56n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.11; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.11
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>
<89e0c7c4-cbaf-4ac0-8f9c-e6c081ccdb56n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <81886bb6-1839-4ee3-a134-9fa0bc84c87fn@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Wed, 02 Aug 2023 17:00:52 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: fir - Wed, 2 Aug 2023 17:00 UTC

środa, 2 sierpnia 2023 o 18:23:38 UTC+2 fir napisał(a):
> ś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 )

i mean bad as general naming sometimes in special cirricumstance maybe could be used (but more like 'local' handy function and c dont much support that) (i mean theoretically some may divide code on small compilation units but i dont find it handy)

Re: strings or enums?

<e5c144a8-daa1-4365-9b8e-590276be6994n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:57b2:0:b0:63c:ffcd:e664 with SMTP id g18-20020ad457b2000000b0063cffcde664mr80082qvx.8.1690995899234;
Wed, 02 Aug 2023 10:04:59 -0700 (PDT)
X-Received: by 2002:a05:6870:d899:b0:1a6:d518:f72c with SMTP id
dv25-20020a056870d89900b001a6d518f72cmr17350294oab.11.1690995898796; Wed, 02
Aug 2023 10:04:58 -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 10:04:58 -0700 (PDT)
In-Reply-To: <d1cc0127-2461-4d44-8337-e11708a00633n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.11; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.11
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> <d1cc0127-2461-4d44-8337-e11708a00633n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e5c144a8-daa1-4365-9b8e-590276be6994n@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Wed, 02 Aug 2023 17:04:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: fir - Wed, 2 Aug 2023 17:04 UTC

środa, 2 sierpnia 2023 o 18:30:47 UTC+2 Malcolm McLean napisał(a):
> 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.

dont belive such researches...problem with that is many of thiose researchers study one or few aspects of given thing and things in reality have often whole pack of aspects and somme need to just try to study it in real...
this is btw also pony curse they belive soem aspect of c++ is better then fall into a 10 pits of other aspects they ignored

Re: strings or enums?

<7a533f8c-dd79-4ca0-afca-76235e609f93n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:b8c3:0:b0:76c:c5bf:6af5 with SMTP id i186-20020a37b8c3000000b0076cc5bf6af5mr39113qkf.14.1690996058389;
Wed, 02 Aug 2023 10:07:38 -0700 (PDT)
X-Received: by 2002:a9d:7f0a:0:b0:6b7:45a8:a80c with SMTP id
j10-20020a9d7f0a000000b006b745a8a80cmr16870753otq.3.1690996058221; Wed, 02
Aug 2023 10:07:38 -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 10:07:37 -0700 (PDT)
In-Reply-To: <e5c144a8-daa1-4365-9b8e-590276be6994n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.11; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.11
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> <d1cc0127-2461-4d44-8337-e11708a00633n@googlegroups.com>
<e5c144a8-daa1-4365-9b8e-590276be6994n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7a533f8c-dd79-4ca0-afca-76235e609f93n@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Wed, 02 Aug 2023 17:07:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2589
 by: fir - Wed, 2 Aug 2023 17:07 UTC

środa, 2 sierpnia 2023 o 19:05:09 UTC+2 fir napisał(a):
> środa, 2 sierpnia 2023 o 18:30:47 UTC+2 Malcolm McLean napisał(a):
> > 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.
> dont belive such researches...problem with that is many of thiose researchers study one or few aspects of given thing and things in reality have often whole pack of aspects and somme need to just try to study it in real...
> this is btw also pony curse they belive soem aspect of c++ is better then fall into a 10 pits of other aspects they ignored

wel in fact thsi is every bodys curse, i could say i also see soem aspects and dont know a lot other..hovever at least i do not take this kind of 'separate aspect' researches too serious

Re: strings or enums?

<uae42t$6h5r$1@bluemanedhawk.eternal-september.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@gmail.com (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: strings or enums?
Date: Wed, 2 Aug 2023 13:34:21 -0400
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <uae42t$6h5r$1@bluemanedhawk.eternal-september.org>
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<uabi6p$3nu9h$1@dont-email.me>
<c5da5543-93f5-4afd-bb6b-4b9e18a92218n@googlegroups.com>
<uae04h$5hi1$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: base64
Injection-Date: Wed, 2 Aug 2023 17:34:22 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="692d2d7ccb7e25c1c82d77235e746113";
logging-data="214203"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iNL/iPktfKn6zHKnyu5U+DnhtrmsZcHA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:HUzp7Jv+8Xbb/ypg3M3EbstftZw=
Content-Language: en-US
In-Reply-To: <uae04h$5hi1$2@dont-email.me>
 by: Blue-Maned_Hawk - Wed, 2 Aug 2023 17:34 UTC

On 8/2/23 12:26, David Brown wrote:
> 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?
>
​I believe what they are referring to is situations of _linking_, not
compilation.
--
⚗︎ | /blu.mɛin.dʰak/ | shortens to "Hawk" | he/him/his/himself/Mr.
bluemanedhawk.github.io
Bitches stole my whole ass ␔🭖᷿᪳𝼗᷍⏧𒒫𐻾ࣛ↉�⃣ quoted-printable, can't
have shit in Thunderbird 😩

Re: strings or enums?

<7f30599f-4bda-48a2-bd05-09b9f2bd25ebn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:5105:0:b0:63c:edce:c71e with SMTP id g5-20020ad45105000000b0063cedcec71emr128214qvp.3.1691009106135;
Wed, 02 Aug 2023 13:45:06 -0700 (PDT)
X-Received: by 2002:a05:6870:a88a:b0:1b0:9596:8931 with SMTP id
eb10-20020a056870a88a00b001b095968931mr18073163oab.11.1691009105905; Wed, 02
Aug 2023 13:45:05 -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 13:45:05 -0700 (PDT)
In-Reply-To: <65d458e0-1e10-4c7c-9973-c371e7afe1d2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.49; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.49
References: <a056e184-c3d8-48ae-9ffe-a3693ebdbbe6n@googlegroups.com>
<a0663885-24c8-4961-b2e6-4ef3bead0e2dn@googlegroups.com> <65d458e0-1e10-4c7c-9973-c371e7afe1d2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7f30599f-4bda-48a2-bd05-09b9f2bd25ebn@googlegroups.com>
Subject: Re: strings or enums?
From: profesor...@gmail.com (fir)
Injection-Date: Wed, 02 Aug 2023 20:45:06 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: fir - Wed, 2 Aug 2023 20:45 UTC

sobota, 29 lipca 2023 o 16:21:43 UTC+2 fir napisał(a):
> 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

this code distribution' or how to call it that also enums make makes them almost not-usable imo (maybe depending on situalion, but when i was using it it was deadly for me and not use it for years, none of my few projects like furia, org-asm, green.fire uses even one enum)

this problem is partially also with structure i guess..you need to jum to definition - hovever its much less for some reason - dont know why, maybe you mat treat structure definition just as a pieco of code, coz structure definition is somewhat like a code.. other thing it is hard to make ad hoc structure (when with enum its natural to have ad hoc enum)

one could define

open struct ship;

and allow to define hields 'adhoc' liek

void foo()
{ ship.x =100;
}

and here you got structure disytibuted but im not sureif this is usable idea...maybe beter is not to define structure at all allowing dods in names and put mehanism to adress groups of varliables like

int ship.x = 10;
int ship.y = 110;
int ship.z = 310;

int ship2.x = 10;
int ship2.y = 110;
int ship2.z = 310;

float dist = distance(ship, ship2); //build structures ad hoc

for longer time i was thinking on this solution but have no final opinion on this its rather good maybe this adhoc building and classic struictures can go in parallel

Re: strings or enums?

<uaej2t$9urb$2@dont-email.me>

  copy mid

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

  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 23:50:20 +0200
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <uaej2t$9urb$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>
<uae04h$5hi1$2@dont-email.me>
<uae42t$6h5r$1@bluemanedhawk.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Aug 2023 21:50:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="46e2fd4c97e01cfd809944807e1c85c2";
logging-data="326507"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18fgywcU/XHq573llJzYqpZxru5yi6+Nn0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:xxGuivODypnDUuGlie13534z5sc=
Content-Language: en-GB
In-Reply-To: <uae42t$6h5r$1@bluemanedhawk.eternal-september.org>
 by: David Brown - Wed, 2 Aug 2023 21:50 UTC

On 02/08/2023 19:34, Blue-Maned_Hawk wrote:
> On 8/2/23 12:26, David Brown wrote:
>> 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?
>>
>
> ​I believe what they are referring to is situations of _linking_, not
> compilation.
>

Linking comes after compilation. Get the compilation right, then link.
The guy is inventing nonsense problems.

Re: strings or enums?

<uaejas$a02e$1@dont-email.me>

  copy mid

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

  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 23:54:35 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <uaejas$a02e$1@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>
<uae079$5hi1$3@dont-email.me>
<d1cc0127-2461-4d44-8337-e11708a00633n@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 21:54:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="46e2fd4c97e01cfd809944807e1c85c2";
logging-data="327758"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HYOkwxhclU8jbYCLUY2KjIJaDCI/RDvk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:LuwNpE5Sd4/fbsD+D0twgWwIA50=
In-Reply-To: <d1cc0127-2461-4d44-8337-e11708a00633n@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Wed, 2 Aug 2023 21:54 UTC

On 02/08/2023 18:30, Malcolm McLean wrote:
> 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.
>

I don't believe you. (I'm not saying you are lying, merely mistaken or
misremembering.)

It is, at best, conceivable that this applies to people whose native
language makes heavy use of concatenation, such as German. And
linguistic studies show that such languages are often harder for
non-native speakers to learn, as well as causing reading and writing
challenges to those that have difficulties already (such as dyslexia,
poor site, low intelligence, etc.).

Re: strings or enums?

<ual9cf$1n79c$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vir.camp...@invalid.invalid (Vir Campestris)
Newsgroups: comp.lang.c
Subject: Re: strings or enums?
Date: Sat, 5 Aug 2023 11:47:43 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <ual9cf$1n79c$1@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>
<uae079$5hi1$3@dont-email.me>
<d1cc0127-2461-4d44-8337-e11708a00633n@googlegroups.com>
<uaejas$a02e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 5 Aug 2023 10:47:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e40b1971f919edac597c786a691593e0";
logging-data="1809708"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187RgyQMY0WD9cxCRj9BM3wzl6W7L21kAA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:Y3RcdjlL1jy8E8cAq45F2zTjkcw=
In-Reply-To: <uaejas$a02e$1@dont-email.me>
Content-Language: en-GB
 by: Vir Campestris - Sat, 5 Aug 2023 10:47 UTC

On 02/08/2023 22:54, David Brown wrote:
> On 02/08/2023 18:30, Malcolm McLean wrote:
>> 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.
>>
>
> I don't believe you.  (I'm not saying you are lying, merely mistaken or
> misremembering.)
>
> It is, at best, conceivable that this applies to people whose native
> language makes heavy use of concatenation, such as German.  And
> linguistic studies show that such languages are often harder for
> non-native speakers to learn, as well as causing reading and writing
> challenges to those that have difficulties already (such as dyslexia,
> poor site, low intelligence, etc.).
>

It's certainly not my experience, and I've never seen a coding standard
that suggests it.

Compare

loadasutf8wthknownformat

with
LoadAsUtf8WithKnownFormat (or loadAsUtf8WithKnownFormat)

or
load_as_utf8_with_known_format

And also think would you spot loadasutf8wthunknownformat?

(I go back far enough to have been stuck with 6 letter uppercase
variables. I never wrote enough ANSI Basic (single letter, or letter
plus 1 digit) for it to matter.)

Andy

Re: strings or enums?

<86jzu9fnf5.fsf@linuxsc.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: strings or enums?
Date: Sat, 05 Aug 2023 09:45:34 -0700
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <86jzu9fnf5.fsf@linuxsc.com>
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> <d1cc0127-2461-4d44-8337-e11708a00633n@googlegroups.com> <uaejas$a02e$1@dont-email.me> <ual9cf$1n79c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="943f511331d2b471aa1b6ebff38979e9";
logging-data="1910536"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZxgPvYpQaoazAKFGLAhmU2++SPt8+A1E="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:6+sI90THiH6hedRF9I7LpNbe8K4=
sha1:fxV2kEWVF+srnUtpnxZ5rJAmLQ0=
 by: Tim Rentsch - Sat, 5 Aug 2023 16:45 UTC

Vir Campestris <vir.campestris@invalid.invalid> writes:

> On 02/08/2023 22:54, David Brown wrote:
>
>> On 02/08/2023 18:30, Malcolm McLean wrote:
>>
>>> 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.
>>
>> I don't believe you. (I'm not saying you are lying, merely
>> mistaken or misremembering.) [...]
>
> It's certainly not my experience, and I've never seen a coding
> standard that suggests it.
>
> Compare
>
> loadasutf8wthknownformat
>
> with
> LoadAsUtf8WithKnownFormat (or loadAsUtf8WithKnownFormat)
>
> or
> load_as_utf8_with_known_format
>
> And also think would you spot loadasutf8wthunknownformat?

The idea that the just-concatenate style is widely preferred or
easier to read is completely deranged. And, I am confident, easy
to debunk through objective experimentation.

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor