🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #208

Re: compare literals / if( "cat"== "dog") {}

#208
From: fir
Date: Sun, 11 Oct 2026 11:13
65 lines
3166 bytes
fir pisze:
> 
> this hashing seems not so bad but it has disadvantages
> 
> tags need to be totally adhoc and if i got
> something
> 
> .type = encode("ship");
> 
> inn add functions than in run function i need
> 
> 
> if(tab[i].type == encode("ship"));
> 
> then it is a bit costly
> 
> and if i want to precompute  it becomes less adhoc
> (maybe not fully like normal shit enum where you got ttally non local 
> shit king definition above both add() and run()..but here you
> got this precomputation above the run..it can be in run
> 
> like
> 
> static k; if(!k)
> {
>   k=1;
> 
>    static int ship, bullet, smoke;
>     ship = encode("ship");
>    bullet = encode("bullet");
>     smoke= encode("smoke");
> 
> }
> 
>   but its not exactly the purest version
> 
> 
> the best version as i said is
> 
> 1) builtin tags in languege
> 2) guaranteea same literals have same pointers
> (is there a reason not to do that?)
> 3) increase those 'djhbsdjhb' literals to work at least 64 bits, 
> preferablu 128 bits


possible other option is maybe define int somewhere above the
add function

int tag_ship;


and in run type

extern tag_ship;

even not caring by value ust compare pointers

advantage is extern can be typed locally in function

distadvantage the definition as far as i know cant

it seems mpre adhoc than shit enum - which as far as i know cant
be defined in parts (in variosy places of code) but its not quite adhoc 
just more than enum (iinw)
Technical Details
Message-ID: <11afr1d$2ir88$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11ae962$2365v$1@dont-email.me> <9tyyS.21373$VDn8.13923@fx14.ams4> <11afcku$2dli3$1@dont-email.me> <11afe36$2e577$1@dont-email.me> <11afe6j$2e577$2@dont-email.me> <11afedm$2e577$3@dont-email.me> <11aff4q$2egej$1@dont-email.me> <11afjjk$2g358$1@dont-email.me> <11afl7v$2giqh$2@dont-email.me> <hGJyS.25112$YNTa.1959@fx01.ams4> <11afpt6$2ib52$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: fir <profesor.fir@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: compare literals / if( "cat"== "dog") {}
Date: Sun, 11 Oct 2026 13:13:45 +0200
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <11afr1d$2ir88$1@dont-email.me>
References: <11ae962$2365v$1@dont-email.me> <9tyyS.21373$VDn8.13923@fx14.ams4>
 <11afcku$2dli3$1@dont-email.me> <11afe36$2e577$1@dont-email.me>
 <11afe6j$2e577$2@dont-email.me> <11afedm$2e577$3@dont-email.me>
 <11aff4q$2egej$1@dont-email.me> <11afjjk$2g358$1@dont-email.me>
 <11afl7v$2giqh$2@dont-email.me> <hGJyS.25112$YNTa.1959@fx01.ams4>
 <11afpt6$2ib52$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 11 Oct 2026 11:13:50 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2714888"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+v/n7hpFD3LSkIImWbrBfopMfXufYCeZE="; posting-host="c78a7ee27a315dc33fa20d18f85fce92"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101
 Firefox/140.0 SeaMonkey/2.53.24
Cancel-Lock: sha1:qpjVWjfVedWoTH9apP84IC0XViE= sha256:1RklPUYlcgOKr9HKxJtP8mu9C4AFtbXwdbhwD+Mt9hg=
	sha1:D1+w3HqhgzPflz7a49/Xc5WAIfA= sha256:sGwrr/dxEwfpMVdS6CcZAaA5gBlDCxhCf8O7dFRGpXg=
In-Reply-To: <11afpt6$2ib52$1@dont-email.me>