Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is it possible to NOT use identifiers named only with _'s?

52 views
Skip to first unread message

J Naman

unread,
Mar 8, 2023, 7:40:53 PM3/8/23
to
_________ = ___(____[________])- (__+___)/(______^_____ ); # Really?
Posts to comp.lang.awk with identifiers named only with _'s are nearly impossible to read, especially on monitors that display multiple _'s as a continuous line (versus small breaks seen in dashes -----).
Thank you for making readable code.

Janis Papanagnou

unread,
Mar 8, 2023, 9:09:43 PM3/8/23
to
On 09.03.2023 01:40, J Naman wrote:
> _________ = ___(____[________])- (__+___)/(______^_____ ); # Really?

Where is that from?

(Kpop had some fun with obfuscated code in the past.)

> Posts to comp.lang.awk with identifiers named only with _'s are
> nearly impossible to read, especially on monitors that display
> multiple _'s as a continuous line (versus small breaks seen in dashes
> -----).

(I'd think it's not the monitor that does the character rendering.)

> Thank you for making readable code.

Either that, or help yourself with a quick and _dirty_(!) hack...

awk 'BEGIN { split("abcdefghijklmnopqrstuvwxyz",_,"") }
{ while(match($0,/_+/)) sub(/_+/,_[RLENGTH]) } ; 1'

produces (with your line above)

i = c(d[h])- (b+c)/(f^e );

HTH.

Janis :-)

Kenny McCormack

unread,
Mar 9, 2023, 12:58:01 AM3/9/23
to
In article <d6a0fdf8-b7e1-4c3c...@googlegroups.com>,
That's the whole point of those posts.
That code is not intended to be readable.

I think that the lunatic who posts those can be safely ignored.

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/RightWingMedia

J Naman

unread,
Mar 9, 2023, 7:34:09 PM3/9/23
to
Janis: What a lovely quick & dirty! I'm putting it in my library under loony_tunes_translator.awk (thanks Kenny!)

Kaz Kylheku

unread,
Mar 11, 2023, 4:10:48 PM3/11/23
to
On 2023-03-09, Kenny McCormack <gaz...@shell.xmission.com> wrote:
> In article <d6a0fdf8-b7e1-4c3c...@googlegroups.com>,
> J Naman <jna...@gmail.com> wrote:
>>_________ = ___(____[________])- (__+___)/(______^_____ ); # Really?
>>Posts to comp.lang.awk with identifiers named only with _'s are nearly impossible
>>to read, especially on monitors that display multiple _'s as a continuous line
>>(versus small breaks seen in dashes -----).
>>Thank you for making readable code.
>
> That's the whole point of those posts.
> That code is not intended to be readable.

As far as the underscores go, it's easy enough to decode.

$ txr demangle.tl
function compare(__, _, ___) {
…. return +__==+___ \
….…. ? _ ~ "[^!]=" \
….…. : (_ ~ "[!=].|.>" || +__<+___)==(_<"=")
}
[Ctrl-D][Enter]
function compare(b, a, c) {
…. return +b==+c \
….…. ? a ~ "[^!]=" \
….…. : (a ~ "[!=].|.>" || +b<+c)==(a<"=")
}

$ cat demangle.tl
(let ((letters (list-seq "a".."z"))) ;; list strings "a" to "z"
(flow
(get-string) ;; get stdin as one big string
(tok #/_+/ t) ;; tokenize
(mapcar [iffi (op starts-with "_") ;; map __ tokens to letters
[chain len pred letters]])
(apply join) ;; reconstitute
(pprint)))

Tokens are defined a sequences of one or more underscores, or else
sequences of other identifiers.

We replace an underscore token by taking the predecessor of its length,
and indexing into the list of "a" to "z" strings: _ maps to a, __ to b
and so on.

A list can be used as a function, which is how letters works in the
expression [chain len pred letters]. When a list is used as a
one-argument function, the argument is a zero-based integer index which
retrieves an element from the list.

Kaz Kylheku

unread,
Mar 11, 2023, 9:12:09 PM3/11/23
to
On 2023-03-11, Kaz Kylheku <864-11...@kylheku.com> wrote:
> $ cat demangle.tl
> (let ((letters (list-seq "a".."z"))) ;; list strings "a" to "z"
> (flow
> (get-string) ;; get stdin as one big string
> (tok #/_+/ t) ;; tokenize
> (mapcar [iffi (op starts-with "_") ;; map __ tokens to letters
> [chain len pred letters]])
> (apply join) ;; reconstitute
> (pprint)))

That exact hack, oblivious to string literals and comments and such, can
be shortened to:

(let ((letters (list-seq "a".."z")))
(flow
(get-string)
(regsub #/_+/ [chain len pred letters])
(pprint)))

and its ilk.

>
> Tokens are defined a sequences of one or more underscores, or else
> sequences of other identifiers.
>
> We replace an underscore token by taking the predecessor of its length,
> and indexing into the list of "a" to "z" strings: _ maps to a, __ to b
> and so on.
>
> A list can be used as a function, which is how letters works in the
> expression [chain len pred letters]. When a list is used as a
> one-argument function, the argument is a zero-based integer index which
> retrieves an element from the list.


--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazi...@mstdn.ca

Kpop 2GM

unread,
Aug 1, 2023, 12:34:14 AM8/1/23
to
believe it or not, I actually directly write code in those underscores even for myself.

like this one - a fully posix-compliant function for ANY awk variant to print out all 1,114,112 Unicode code-points to encoding specs of UTF-8 (default), UTF 16 LE/BE (including surrogates), and UTF 32 LE/BE, or any single arbitrary byte (with the sole exception being nawk's inability to properly handle the \0 null byte),

all while needing a total of just 4 local variables (that's inclusive of the 2 variables for accepting input),
performs data cleansing and input range clamping,
has ZERO dependency on hard-coded magic numbers for cutoffs, scalars, offsets etc (since they're all generated on the fly as part of the input cleansing process setup),
has zero external function calls other than the built-in functions of int( ) and sprintf( ),
is entirely loop-free and recursion free,
can circumvent certain awk variant restrictions (like gawk refusing to print anything correct for negative inputs to "%c"),
and can output in UTF16 or UTF32 even when locale is in ASCII mode.

function.chrUC8(__, _, ___, ____).{
....#
....#.__|.Unicode.code.point
....#.....outside.U+0000.-.U+10FFFF:
....#.....-->.UTF-8/16/32.clamps.to
....#............8/16/32-bits.respectively
....#.....-->.U8.mode.also.clamps.U16.surrogate.ranges
....#
....#.._|.[1].missing,.empty.string.input,.or
....#.........numeric.zero.:.U8
....#.....[2].+/-.16/32.:
....#............-16....:.UTF-16.LE
....#...............+32.:.UTF-32.BE.|._+_.optional:
....#.....[3].anything.else.:
....#.........direct.pass-through.to.built-in.encoder;
....#.........inputs.not.clamped.or.pre-sanitized
....#
....#...|--->.UC.codepoint.byte-encoded.in
....#............requested.encoding.format,.1-4.bytes
....return.\
....((____=___=_+=((_~!!_)<(""<_))*!+_)*_\
.....................).>=.(_+=_+=_^=_<_)^_\
....?.(___*___.==._^_.\
........?.(.((__.=.(-(__=int(__)).<=.+__.&&
..........__.<.((_+_)^_.*.(_*_.+._^_))).?.\
..........__.:.(__.%.(___.=_^(_+_))+___).%.___).\
........*.(____.=._*_.==.-____)^!_\
........*.(___.=._^_*(_+(--_+_)^_))^!_)<--_^_^_^_++.\
........?.sprintf("%c%c",.int((__=____*(_^=++_).\
............?.__%_*_+int(__/_).:.__)/_)+___,__%_+___).\
........:.sprintf("%c%c%c%c",.int((__.=.____*(____=.\
............int((__-=++_^(_+_))/_^_/_)-_^_*_+___).*.\
...............................(__.=.__%(_*(_^=_))+___).\
............?._*(____%_*_+int(____/_)).*_.+.__%_*_.+.int(__/_)\
..................:.__+_*____*_)./_./_./_).+.___,
............int(__/_/_).%_+___,int(+__/_).%_+___,__%_+___).\
.....).:.(+___.<.-___).==.(___.=.(--_+_)^_.*.(_.^=.++_).)^!_.\
........?.sprintf("%c%c%c%c",.(__.=.int(__).%.(_*_*_*_))%_+___,
............int(__/_).%_+___,.(__.=.int(__/_/_))%_.+.___,.int(__/_)+___)\
........:.sprintf("%c%c%c%c",.int((__.%=._*_*_*_)./_/_/_).+.___,
............int(__/_/_)%_+___,int(__/_).%_.+.___,.__%_.+.___).\
.................................).\
.................................:..+___..||
..........(((__=+__)+__)<_^_.&&.-__<=+__).||
......((___=(--_+_)^_*++_^_)<=__.&&.__<(_^_*(_+_)+___)).||
..................................+__<-__.||
..............................((_+_)^_*(_*_+_^_))<=__\
........?.sprintf("%c",+___<_?__:.(__%(_^=_)+_)%_+___)\
....:.(__+__)<(_+_)^_..................................\
........?.sprintf("%c%c",.(___.+=.(_*=_*_)+_).+_+.int(__/_),.__%_+___).\
....:.__<_^(_+_)....................................................\
........?.sprintf("%c%c%c",._*(_+_).+.(___.+=.(_*=_*_)+_).+_+.int(__/_/_),
.....................................int(__/_)%_.+.___,.__%_.+.___).\
........:.sprintf("%c%c%c%c",._*-_+.(___.+=.(_*=_*_)+_).+_+_+.int(__/_/_/_),
.................int(__/_/_)%_+___,.int(__/_)%_.+.___,__%_+___)
}

Janis Papanagnou

unread,
Aug 1, 2023, 11:22:38 AM8/1/23
to
On 01.08.2023 06:34, Kpop 2GM wrote:
>> On 09.03.2023 01:40, J Naman wrote:
>>> _________ = ___(____[________])- (__+___)/(______^_____ ); # Really?
>
> believe it or not, I actually directly write code in those underscores even for myself.

I wonder why.

Janis

0 new messages