Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Understanding void.h

Name: Anonymous 2016-01-25 19:02

So i've checked FV github to see it was empty.
Apparently FV is too stupid to use git and keeps void.h in gists.
From https://gist.github.com/FrozenVoid/87e6ad6212ac9ce496e0

1.The thing you notice first is everything depends on _VFUNC which actually does nothing but concatenate with ##
Its in varmacro.h and the system is based on http://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments bruteforce approach that creates a macro for every number of arguments. Its cute but limited to 63 arguments and requires writing 63 macros each time: he used this approach in early commits in the gist file.
What FV has done is to replace the 63 macros per macro with apply: same 63 macros but they carry a function macro as first argument and switch to next apply(N-1) with remaining arguments. There are several of these apply functions, most of them i couldn't understand, before writing some test code.
apply.h and apply2.h are the largest files in there along with argmacro.h.

2. _Generic abuse. If you preprocess the files which use p() macro the horrible mess of nested _Generics comes to front, hidden in type selection macro: the type selection...is just macro applied to the type list, another _Generic macro that has all the types.

3.tuple.h this one is quite interesting: using macro argument lists kept in parens as compile-time objects. The next trick is converting the "tuple" back into argument list:
Its not in tuple.h but counter-intuitevely in varmacro.h

#define wrap(...) __VA_ARGS__
#define detuple(...) wrap __VA_ARGS__
Basically when a "tuple" like (1,2,3) is passed to detuple it strips the parens off it, because wrap assumes the parens are its arguments and returns them back.
4.There are actually car and cdr in there: in the argmacro.h there is curious "rest" macro that strips off the first N arguments from its arguments and frontrest macro which return back first N arguments.
They apparently work by passing the argument list N times so it either cut N front arguments or preserves the N first arguments. Neat.

5.The key of array.h - the foreach macro: i was first curious how it find out the size of array, the trick he used is in mem.h elems() macro that uses size() a dirty macro hack that either returns sizeof or msize(): a call to check heap object length in bytes if its sizeof() equal to size of pointer. Here it is:
#define size1(arg1) ({u8 lensize=sizeof(arg1);\
once;\
if((lensize!=sizeof(vp)))break;\
if(isarray(arg1)|isbasic(arg1)){;break;};\
lensize=msize((vp)(u8)arg1);endonce;\
;lensize;})
void.h isn't that cryptic as it seemed at first glance.

Name: Anonymous 2016-01-25 20:14

FrozenAnus

Name: Anonymous 2016-01-25 23:40

>>1-2
Thanks for looking after yourself.

Name: Anonymous 2016-01-26 5:46

>>1
Obviously stolen from BoostPP

Name: Anonymous 2016-01-26 6:02

JACKSON 5 GET

Name: Anonymous 2016-01-26 6:06

>>4
What??? BoostPP is ancient shit it doesn't use macro overloading: its a modern technique.

Name: Anonymous 2016-01-26 6:10

>>1
You could ask it on my forum instead of trial and error.

Name: Anonymous 2016-01-27 16:58

Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

Name: Anonymous 2016-01-28 7:26

It's beautiful.

Name: Anonymous 2016-01-28 8:18

Isn't msize non-portable?

Name: Anonymous 2016-01-28 9:06

check em

Name: Anonymous 2016-01-28 12:07

How the fuck is this an "lispeval":
#define tapplyfunc0(func) func
#define tapplyfunc1(func,args...) func(args)
#define tapplyfunc(args...) _VFUNC(tapplyfunc,reduce1arg(nargs(args)))(args)

#define tapplyf(t) tapplyfunc(sdt(t))
#define lispeval(tuples...) sm opapply(;,tapplyf,tuples) em

Name: Anonymous 2016-01-28 12:13

>>12
It's not. IMO, void.h is pretty retarded piece of code.

Name: Anonymous 2016-01-28 13:13

Author of Void.h AMA:
the concept of 'executable tuples' is a remote relative of lisp eval - its useful in some cases when macro-constructed macros/tuples/functions need to be encapsulated in blocks(it doesn't care if the arg is function/macro or tuple-expression like (func(),func2(),4) (which returns 4).
lispeval goes likes this:
1.sm em({;start_macro end_macro;}) is a GCC extension called statement expression macro(statement block), the last value-expression of which is returned by lispeval.
https://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Statement-Exprs.html

2.opapply is executed inside the #1 expr, it invokes tapplyf and separates invocations by semicolons, creating:
({; tapplyf(arg1);tapplyf(arg2);tapplyf(arg3);...;tapplyf(Lastarg1);})
The last tapplyf is going to be the value-expression returned.

3. tapplyf( tuple apply func):
passes its arguments to tapplyfunc, expanding tuples into arglist if the argument is a tuple(sdt== safe detuple)
tapplyf((apply,query,data...))
becomes tapplyfunc(apply,query,data...)

4.tapplyfunc checks how much arguments it gets:if one, the argument is inserted into expr as is, e.g. it could be a second level tuple like ((anything,a,(4.4),(3,4))) or some direct expression literal(anything is only detupled once: to nest eval you need to explicitly include eval as the tuples first arg ).
If there are more than one arguments, the first argument is treated as function and rest as arguments:
tapplyfunc(apply,query,data...)
becomes apply(query,data...)
which expands to query(dataarg1),query(dataarg2),...

Name: Anonymous 2016-01-28 14:17

Author of Void.h AMA:
Why the hell did you create this kind of sad crap?

Name: Anonymous 2016-01-28 14:56

>>15
because unlike Lisp its useful.

Name: Anonymous 2016-01-28 15:21

>>16
Lisp is far more useful than some crappy C headers.

Name: Anonymous 2016-01-28 15:47

>>17
Lisp has a large CPU/Ram overhead thats inherent due its design.
99% of useful things it does is reducing amount of code written: Lisp macros to generate Real code that will run(at runtime) and Lisp code will do the same thing C code does 99% of time.
void.h macros remove most of the "abstraction cruft" which Lisp also remove at cost of performance.
Since the preprocessor is (besides compile-time) a zero-cost abstraction the generated code doesn't suffer any performance penalty for using it.
Lisp generates crappy Lisp code or converts Lisp to crappy C ocde that is inferior to code made with C macros.
Process:
Lisp->code.lisp-(slow)>lisp.c(Lisp-to-C translated)->GCC(optimize)->code.asm
Void.h(zero-cost C macros)->code.c(real C)->GCC(optimize)->code.asm
Some Lisp compilers don't rely on GCC: they produce even worse code. And interpreters..worse than python/ruby.
Lisp compilers would actually be useful if they were generating C code from macros like void.h without any Lisp concepts in result(i.e. text generator that produces C code from macro-blocks). Since C macros already proven to be as versatile as Lisp, the case of using Lisp is quite weak anyway and considering the syntax())( probably useless.

Name: Anonymous 2016-01-28 22:21

>>18
I have no idea how Lisp works, please ignore.
Okay, thanks for sharing.

Name: Anonymous 2016-01-28 22:56

>>19
Who are you quoting?

Name: Anonymous 2016-01-29 0:16

>>19
He never said that though.

Name: Anonymous 2016-01-29 0:41

>>21
Oh, he certainly did.

Name: Anonymous 2016-01-29 1:46

>>20
being an anus

Name: Anonymous 2016-01-29 2:40

>>23
Who are you quoting? It certainly isn't Milkribs.

Name: Anonymous 2016-01-29 5:41

>>19
Lisp is essentially a simplified XML parser which modifies the XML node tree at runtime(like DOM modification in HTML pages via JavaScript,except the code is encoded in XML), which at end is converted to C code blocks to compile(via GCC) or assembler fragments to combine into object executable file.

Name: Anonymous 2016-01-29 6:11

>>25
The key insight as to why simple C macros are more powerful than Lisp is this:
Lisp operates on the Level of DOM node manipulation - C macros are innerHTML manipulators that bypass Node boundaries and modify the raw text, instead of obeying XML rules. While on the surface C macros seem primitive they operate on a lower level where they have less restrictions and safety checks.
I predict that extending C preprocessor would benefit the software industry much more then inventing another crippled XML processor.

Name: Anonymous 2016-01-29 9:37

>>25
since lisp came first, you mean that xml is a lisp with angle brackets, but without parser, compiler, or interpreter built-in?

Name: Anonymous 2016-01-29 9:50

>>18
chez scheme and stalin produce worse code than hand-written C

Name: Anonymous 2016-01-29 10:02

>>27
XML follows independent evolution from Lithp.
XML(1997 Michael Sperberg-McQueen) <- SGML(late 1970's http://www.sgmlsource.com/history/roots.htm ISO 8879: Standard GML ) <- GML (1969 Charles Goldfarb, Edward Mosher, and Raymond Lorie) <-(1968 IBM SCRIPT https://en.wikipedia.org/wiki/SCRIPT_%28markup%29 ) <-1967 from IBM https://en.wikipedia.org/wiki/CP/CMS
https://en.wikipedia.org/wiki/History_of_CP/CMS#Historical_notes (The only place where Lithp intersects with XML is this:

Role of John McCarthy (of LISP fame) in timesharing: "At about this time [April 1961] John McCarthy… gave a special evening lecture [stressing the future importance of time-sharing that] ended on the speculative note that computation might eventually 'be organized as a public utility, just as the telephone system is a public utility.' This insightful prediction can be seen to anticipate the role of the Internet. Similar sentiments were later expressed forcefully by Alan Kay and others. IBM leadership had a very different view of computation.[15]

Name: Anonymous 2016-01-29 10:10

>>28
They produce only Lisp-to-C code: a restricted subset of C which is then compiled.
C macros allow you to create unlimited, unrestricted C code with the same abstraction level. C macros allow anything:Lisp code allows using a subset-of-C which is overburdened with Lisp overhead and runtime cost.
Stalin Scheme is an exception rather than a rule: it produces better C code(yet more restricted than hand coded C) than most Lisp compilers, but has some restrictions that make it less popular than other Lisps.

Name: Anonymous 2016-01-29 10:52

>>28
Whom are you quoting?

Name: Anonymous 2016-01-29 11:05

>>32
Its an abstract quasi-quotation isomorphism, you wouldn't understand.

Name: Anonymous 2016-01-29 11:21

>>30
How is compile-time C not overhead, while compile-time Lisp supposedly is? You, sir, are confused and ill-informed.

Name: Anonymous 2016-01-29 11:30

>>33
Compile time C produces C code.
compile-time Lisp transform Lisp into a form that resembles C code but is actually something like Lisp Virtual Machine, a runtime that abstracts Lisp into a restricted subset of C.
Then this "Lisp Virtual Code" is transformed into a mess of C code blocks that GCC has to optimize.
The overhead is in the produced code, not the compilation time.

Name: Anonymous 2016-01-29 17:34

>>34
are you high

Name: Anonymous 2016-01-30 3:32

>>34
On one hand, it is sort of amusing seeing how consistent and adamant you are about this.

On the other hand, you're making a complete ass of yourself in proudly showcasing your complete ignorance and need to kill yourself.

Name: Anonymous 2016-01-30 7:13

>>36
Another blubbering Lisptard being an ignorant and deluded clown.
https://raw.githubusercontent.com/holdenk/stalin-hax/master/stalin-IA32.c (Stalin Scheme)

Name: Anonymous 2016-01-30 8:47

>>37
Another blubbering actual retard who knows very little about 1 shitty language dialect, and thinks he's hot shit. You know nothing, Jon Snow. Stop trying to talk about it.

Name: Anonymous 2016-01-30 8:53

Lisp is bloated shit though. I can say that without even reading the thread. If half as much time was spent optimizing the interpreter\compiler as was spent merely telling people to write macros to produce optimized executables, LISP would be fast enough to complete an infinite loop in less than an hour. It's a shame that such great, expressive, powerful languages as the Lisp family suffer from the equivalent of a C compiler maker telling people that if they don't like the shit outputs, to just write their own toolchain but to keep the at-fault component until the bitter end.

Name: Anonymous 2016-01-30 9:04

>>38
1 shitty language dialect
This is Stalin Scheme the fastest Lisp/Scheme language on the planet with most sophisticated flow/IPO optimizations found in the language family. It produces near-C speed code and often outperforms naive C. The file Stalin generates for its compiler >>37 is a bit bloated, but is trivial for GCC to optimize into real tight assembler.

Name: Anonymous 2016-01-30 9:53

Name: Anonymous 2016-01-31 1:07

>>39
The Lisp community is made up of Lisp implementers and Lisp users. The implementers continually make the compilers generate better code. I've never seen an implementer tell users that they don't care about optimization and to just write better code. The workforce is much smaller than C. I don't see the problem, except you think there's a problem which doesn't exist.

Name: Anonymous 2016-01-31 5:36

>>42
Closed as:WONTFIX
problem cannot be replicated.

Name: Anonymous 2016-01-31 15:45

Written in Notepad without copy and paste, I assume

Name: Anonymous 2016-02-01 10:22

>>44
*Programmer's Notepad
*Copy-paste-alter was often used.

Name: Anonymous 2016-02-01 18:21

>>45
Never change.

Actually, you have two options. Change, or stop posting.

Name: Anonymous 2016-11-17 21:15

>>39
LISP would be fast enough to complete an infinite loop in less than an hour.
Wow, you're actually retarded. An infinite loop can be implemented in a single assembler instruction, so all the compiler has to do is detect an infinite loop - which is itself trivial (verify that the loop condition doesn't depend on external state, and that any changes to internal state that occur in the loop cannot cause the loop to exit) - and then emit a simple jmp instruction. Any decent computer (by which I mean anything more powerful than a Zuse Z1) should be able to compile that loop in minutes if not milliseconds.

Name: Anonymous 2016-11-18 10:17

Apparently FV is too stupid to use git
Because after i tried to install to bloated Github desktop for windows they shilled, i decided to use it as pastebin with revision control instead. I don't feel like using bloatware.
Basically when a "tuple" like (1,2,3) is passed to detuple it strips the parens off it
Actually detuple uses the trick that func_call (arguments) is the same as func_call (tuple) : the tuple just becomes arguments and the parens evaporate with function macro expanded.
There is nothing magical in detuple at all: it just unsafe to use it directly to remove parens, there is safedetuple that checks if the argument is actually a tuple or not(by speculatively expanding it and counting the resulting arguments(with nargs/reduce1arg:1+ args reduces to 1,0 to 0) :
#define istuple(tupletest...) reduce1arg(nargs(detuple(tupletest)))
#define safedetuple(possibletuple...) _VFUNC(detuple,istuple(possibletuple))(possibletuple)
nested _Generics
the GCC intrinsic is way worse(imagine the below nested 4 levels):
#define foo(x) \
({ \
typeof (x) tmp = (x); \
if (__builtin_types_compatible_p (typeof (x), long double)) \
tmp = foo_long_double (tmp); \
else if (__builtin_types_compatible_p (typeof (x), double)) \
tmp = foo_double (tmp); \
else if (__builtin_types_compatible_p (typeof (x), float)) \
tmp = foo_float (tmp); \
else \
abort (); \
tmp; \
})

The key of array.h - the foreach macro:
I've explained it here: http://bbs.progrider.org/prog/read/1479394498/14 since it comes up often

Name: Anonymous 2016-11-18 11:10

>>48
who cares about desktop apps? why don't you just use cmdline git?

Name: Anonymous 2016-11-18 11:24

>>49
I don't see how its more convenient than copying and pasting code into wiki entries(which i currently use) which have revision history.

Name: Anonymous 2016-11-18 11:28

>>50
we talked about it before. it allows easy automation projects (just git clone it to have the whole project in a new directory, then git commit push && git push to apply changes remotely and git pull to download stuff if local repo is not up to date). it also allows branching, but that's not as useful if you work alone and don't maintain multiple versions.

Name: Anonymous 2016-11-18 11:35

>>51
easy automation
Directory synchronization is not a killer feature, especially if you have to type the thing you advertise instead of pushing (Synchronize) button.
it also allows branching
I can maintain multiple versions in separate wiki entries.

Name: Anonymous 2016-11-18 11:44

>>52
Directory synchronization is not a killer feature, especially if you have to type the thing you advertise instead of pushing (Synchronize) button.
yeah, because typing git push is so much more work than:
1. opening a browser
2. navigating to the wiki
3. finding the correct article
4. clicking 'edit'
5. opening IDE or text editor in a separate window
6. copying everything
7. pasting everything into the browser
8. clicking 'save'.
I dunno, I do most of my work from shell so typing a short one-liner is natural to me
I can maintain multiple versions in separate wiki entries.
and what if you want to make a common update to different versions? there's no git merge on a wiki.

Name: Anonymous 2016-11-18 12:35

1. opening a browser
My browser is always open. 1 click to switch
2. navigating to the wiki
Clicking the wiki favicon in the favicon bar(a compact bookmark bar)- 1 click
3. finding the correct article
Scroll and click one article in https://www.reddit.com/r/frozenvoid/wiki/pages/ 1click
4. clicking 'edit'
One click
5. opening IDE or text editor in a separate window
Always open 1 click to switch
6. copying everything
right-click + copy
7. pasting everything into the browser
Right-click + paste
8. clicking 'save'.
1 click

10 clicks. All are trivial and can be done within seconds.
even a single [git commit] is 10 letters to type.

Name: Anonymous 2016-11-18 12:50

>>54
but that's 10 click for each file separately. but whatever, I'm used to CLI so maybe it's more natural for me than it is for you

Name: Anonymous 2016-11-18 12:51

>>54
It takes much less to type 10 letters than to click 10 links though. That's a retarded comparison you're making there.

Name: Anonymous 2016-11-18 13:13

>>55,56
If you like typing, why you need macros at all??
Also, typing that much commands should be replaced by a shell scropt, something Synchronize[DirectoryName]ToGithub.sh and place it on desktop to one-click sync. It would be far more productive than typing stuff every time.

Name: Anonymous 2016-11-18 13:23

>>57
this implies you have a desktop with icons. this is not true for all desktop environments/window managers. as for shell scripts - yes, the advantage of CLI is you can use them (although I wouldn't write a script just for 10 fucking characters - I also wouldn't write a macro for 10 fucking characters). on the other hand, trying to script a browser to automate wiki editing would be a huge pain in the ass.

Name: Anonymous 2016-11-18 13:26

Also, just put it to crontab as @hourly Synchronize[DirectoryName]ToGithub.sh
if you need automation.

Name: Anonymous 2016-11-18 13:32

>>59
again, this is only possible if you use git (or other VCS). how would you do that with a wiki? selenium?

Name: Anonymous 2016-11-18 13:38

>>58
script a browser to automate wiki editing
But I don't want to automate that. I "wouldn't write a script just for 10 fucking characters" because i commit changes rarely in proportion to work done. Copy-pasting a dozen files few times per week is not that great of a burden - it doesn't justify making revisions for every small commit.
Basically there are two philosophies:
1. >>59 for committing every tiny change. Unstable/Untested code
2. Committing different versions/releases with large changes.
Stable/Tested code

Name: Anonymous 2016-11-18 13:45

>>61
it's better to commit untested code and then revert back to stable version than to lose good code to disk failure or similar shit

Name: Anonymous 2016-11-18 13:51

>>62 What kind of minimum validity you have for code? That it compiles? that its correct? What is actually "Good code" if it doesn't work?

Name: Anonymous 2016-11-18 13:53

>>63
if it compiles and passes assertions and sanity checks, it's good enough to go to source control. if then I notice a bug that wasn't there before, it's relatively easy to track down the problem with git blame and then revert to an older version

Name: Anonymous 2016-11-18 14:08

>>64 wiki history revision comparison:
Just click on 2 dates and click compare, it will lists all changes with line by line.
Git blame is arcane in comparison:
https://git-scm.com/docs/git-blame

My view is that wiki model is superior as it creates more user-friendly form of revision control.
https://www.reddit.com/r/frozenvoid/wiki/websites/version_control/code_versioning_systems_alternatives

Name: Anonymous 2016-11-18 14:22

>>65
but revision control can be user-friendly too. that is what github does: you have a commandline interface and a fully-featured web interface (you can edit everthing from your browser if you want). git is a backend that allows for automation and scripting but it's possible to use a GUI with it. on the other hand, wiki doesn't allow for easy automation.

as for git blame vs wiki history: wiki history shows changes between two arbitrary dates. git blame shows who and in which revision edited each line. this is completely different - sometimes you don't want to know what changed since yesterday, rather you'd like to see why is there a line that causes a buffer overflow (and who the fuck added it if there are many commiters).

Name: Anonymous 2016-11-18 15:01

>>66
sometimes you don't want to know what changed since yesterday
Actually i want to see what changed - its far more common to search for code changes not for the person(its still possible to narrow down the date range to find exact revision much faster than it takes to tinker with git blame: by splitting the revisions in two and checking ).
The scenario of a project that has many committers active every day is probably not that common anyway("team coding" or w/e corporate non-sense), Linux kernel itself has barely a dozen commits per day on github.

Name: Anonymous 2016-11-18 15:11

(also i have to add it would be unlikely for me to allow anyone to alter my code, or even accept unmodified patches)

Name: Anonymous 2016-11-19 1:21

check em

Name: Anonymous 2016-11-19 2:03

I used to think FV was just trolling but now I understand he is legitimately quite insane

Name: Anonymous 2016-11-19 4:51

>>70 Don't talk to me or my header ever again.

Name: Anonymous 2016-11-19 6:18

Seems that in addition to void.h our own FV is a prolific fanfic author:
https://www.fanfiction.net/u/1214891/Frozen-Void

Don't change these.
Name: Email:
Entire Thread Thread List