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

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-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

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