Discussion:
Is it possible to NOT use identifiers named only with _'s?
(too old to reply)
J Naman
2023-03-09 00:40:52 UTC
Permalink
_________ = ___(____[________])- (__+___)/(______^_____ ); # 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
2023-03-09 02:09:40 UTC
Permalink
Post by J Naman
_________ = ___(____[________])- (__+___)/(______^_____ ); # Really?
Where is that from?

(Kpop had some fun with obfuscated code in the past.)
Post by J Naman
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.)
Post by J Naman
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 :-)
Kpop 2GM
2023-08-01 04:34:10 UTC
Permalink
Post by Janis Papanagnou
_________ = ___(____[________])- (__+___)/(______^_____ ); # 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 :-)
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
2023-08-01 15:22:35 UTC
Permalink
Post by Kpop 2GM
_________ = ___(____[________])- (__+___)/(______^_____ ); # Really?
believe it or not, I actually directly write code in those underscores even for myself.
I wonder why.

Janis

Kenny McCormack
2023-03-09 05:57:57 UTC
Permalink
Post by J Naman
_________ = ___(____[________])- (__+___)/(______^_____ ); # 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.

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
2023-03-10 00:34:08 UTC
Permalink
Post by Kenny McCormack
_________ = ___(____[________])- (__+___)/(______^_____ ); # 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.
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
http://user.xmission.com/~gazelle/Sigs/RightWingMedia
Janis: What a lovely quick & dirty! I'm putting it in my library under loony_tunes_translator.awk (thanks Kenny!)
Kaz Kylheku
2023-03-11 21:10:45 UTC
Permalink
Post by Kenny McCormack
Post by J Naman
_________ = ___(____[________])- (__+___)/(______^_____ ); # 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
2023-03-12 02:12:06 UTC
Permalink
Post by Kaz Kylheku
$ 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.
Post by Kaz Kylheku
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: @***@mstdn.ca
Loading...